473,800 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session termination issue

Hi,

I'm trying to tweak the logout script on my web projects. When I point
users to a logout.php page containing the session_destroy () function, I
get the "Trying to destroy uninitialized session" error.

Any ideas?

Thanks.

Jun 18 '06 #1
8 2262
TristaSD wrote:
Hi,

I'm trying to tweak the logout script on my web projects. When I point
users to a logout.php page containing the session_destroy () function, I
get the "Trying to destroy uninitialized session" error.


Gets initialized with "session_st art"

See the example:
http://www.php.net/manual/en/functio...on-destroy.php

--
/Bent
Jun 18 '06 #2
I tried to follow php.net manual to the best of my ability, but I'm
getting two errors now:

Warning: session_start() : Cannot send session cache limiter - headers
already sent
Warning: Cannot modify header information - headers already sent by

All I want to do is create a login page that starts the session, and a
logout page that destroys the session. I'm having a hell of a time.

Jun 18 '06 #3
Message-ID: <11************ *********@f6g20 00cwb.googlegro ups.com> from
TristaSD contained the following:
I tried to follow php.net manual to the best of my ability, but I'm
getting two errors now:

Warning: session_start() : Cannot send session cache limiter - headers
already sent
Warning: Cannot modify header information - headers already sent by

All I want to do is create a login page that starts the session, and a
logout page that destroys the session. I'm having a hell of a time.

Logout.php
<?php
session_start() ;
session_destroy ();
header("Locatio n: login.php");
exit;
?>


--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jun 18 '06 #4
TristaSD wrote:
I tried to follow php.net manual to the best of my ability, but I'm
getting two errors now:

Warning: session_start() : Cannot send session cache limiter - headers
already sent
Warning: Cannot modify header information - headers already sent by
Make sure you don't have any output before calling session_start. Not even a
space or a newline.
All I want to do is create a login page that starts the session, and a
logout page that destroys the session. I'm having a hell of a time.


You'll get there. Just remember that session_start needs to be called in all
pages that uses the session-functions or access the session data.

--
/Bent
Jun 18 '06 #5
TristaSD wrote:
I tried to follow php.net manual to the best of my ability, but I'm
getting two errors now:

Warning: session_start() : Cannot send session cache limiter - headers
already sent
Warning: Cannot modify header information - headers already sent by

All I want to do is create a login page that starts the session, and a
logout page that destroys the session. I'm having a hell of a time.

Post your code. It's the fastest way to get help.

In general, your problem is that some character data (could be as simple
as a blank or carriage-return) is being sent before your session_start() .

-david-

Jun 19 '06 #6
Geoff Berrow wrote:
Message-ID: <11************ *********@f6g20 00cwb.googlegro ups.com> from
TristaSD contained the following:
I tried to follow php.net manual to the best of my ability, but I'm
getting two errors now:

Warning: session_start() : Cannot send session cache limiter - headers
already sent
Warning: Cannot modify header information - headers already sent by

All I want to do is create a login page that starts the session, and a
logout page that destroys the session. I'm having a hell of a time.

Logout.php
<?php
session_start() ;
session_destroy ();
header("Locatio n: login.php");
exit;
?>


My logout is a little more involved:

<?php
require_once('a utoload.inc');
require_once('r edirect.inc');

session_start() ;

$sessionName = session_name();
$sessionCookie = session_get_coo kie_params();

session_destroy ();

setcookie($sess ionName, false, $sessionCookie['lifetime'],
$sessionCookie['path'], $sessionCookie['domain'],
$sessionCookie['secure']);

redirect('/ctrl/login.ctrl.php' );
?>

-david-

Jun 19 '06 #7
Thanks, all. It seems to work now, but some things are still very odd.
For example, when I go to www.mysite.com/session, I get "session
doesn't exist". When I refresh, however, I get the session id. I get
the session ID when I go to www.mysite.com/session/index.php directly.
Is it a default page issue? Why is the session started when I go to
index.php, but not /session/ ?

Here's the code:

*** index.php ***
<?session_start ();?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Sessio n Testing</title>
</head>

<body>
<? echo ($PHPSESSID ? "Session $PHPSESSID exists. You can now <a
href=\"logout.p hp\">log out</a>." : "Session does not exist."); ?>
</body>
</html>

*** logout.php ***
<?session_start ();
session_destroy ();
//header("Locatio n: index.php");
echo "Session destroyed.";
exit;?>

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Sessio n Destrustion</title>
</head>

<body>
</body>
</html>

Jun 20 '06 #8
Many "random" errors on php sessions are caused when tring to read the
same file from two different process (and one has the session's file
locked).
Have you tried closing the session for output (leaving it open only for
reads) with session_write_c lose()? I solved many session issues witht
this.

PS: I don't remember the exact function name

Jun 21 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1365
by: Alexander Staubo | last post by:
Python does not seem to clean up gracefully on SIGTERM: The exit sequence is not invoked on termination, so the atexit module cannot be used to install shutdown logic. Further, while the signal module allows trapping the signal, it does not offer a truly portable way of respecting the termination request. As far as I can see, this issue has been a topic of conversation for years, but I don't see that it has ever been solved: ...
7
4202
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same code for 6 hours and stops. I've found the problem to be the Set MySession = CreateObject("MAPI.Session")
3
7226
by: JezB | last post by:
I want to clear some specific Session variables when the user closes a page. On my page I have a "return to ..." button which navigates back to the parent page from which it was invoked - under the click event of this button I clear my Session variables. However, how can I capture the fact that the page has been finished with, to clear my session variables, if the user (a) navigates away from the page directly by entering a URL, (b)...
5
2202
by: ASP.Confused | last post by:
As you can tell from my previous posts on this issue...I'm really confused :-/ I have a few ASP.NET web applications on my web host's "https" server. Our web host has a single "bin" folder for me to toss my assemblies into. We keep loosing session state every few months. People have told me that my app could be running out of memory, causing the sessions to get reset. Well, if this is the case, then when I go to the page again,...
5
5295
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the sessionstate inproc mode and users are randomly losing their session. I do not believe it is happening across all users at one time. It seems to happen to different users at different times, but I am only going off heresay. The aspnet worker...
10
2192
by: Li Pang | last post by:
Hi, I created a html page from which I give a link to another web site. The new site is opened in a new window. When I opened multiple windows, they all have the same SessionID. I want ot know how to open the windows with different sessionID. Thanks
669
26251
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
8
1998
by: Michael Schwarz | last post by:
Hi, I have a problem where I have two requests (i.e. two different windows that are using the same session) that are accessing the session collection. The requests will need more time on the server, but I get the problem that the two sessions are not getting updated values from each requests. Is this by design or is there any solution to do this? -- Best regards | Schne Gre
3
1657
by: Chris Gilpin | last post by:
Hey everyone, this one is a doozie (for me at least) I have a large table (>1M entries) that contains Client IDs and Visit Dates I am trying to create a query that will indicate when a client starts a new session and the date of, and when the client ends a session and the date of termination. A session is ended if the client is inactive for X (say 21) days. I have done this by exporting the table to Excel and writing code in Excel, but...
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.