473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Session close, destroy and regenerate

I have a script that has confirmed a user's login credentials and wants to
move onward. I want to regenerate the session ID, so I have code something
like this:

$_SESSION = array(); // Wipe the in memory data
session_destroy(); // Wipe the on disk data
session_regenerate_id();
$_SESSION['username'] = $_POST['username'];
$_SESSION['authorised'] = True;
$_SESSION['active'] = True;
header( "Location: http://" . the_index_page...

The objective is to wipe everything to do with the session and start
completely afresh.

This code doesn't work as I want, because the session_destroy() doesn't
actually remove the data on the disk until the script exits. What appears
to happen is the session in memory is cleared, the new ID correctly
generated, the new session is populated, and then the new session is
destroyed! By the time the index page loads the session is empty again,
because the file on disk is empty.

Removing the session_destroy() allows things to work, but leaves traces in
the file in the temp directory. See the comment by licp at
http://au2.php.net/manual/en/functio...enerate-id.php. The post
on that page by chris appears to do what I want but he uses a
session_close() function which doesn't exist (at least not in PHP 4.3.4
which is what I'm using on SUSE Linux).

So the question is, how can I completely wipe a session and start a new one?

--
The email address used to post is a spam pit. Contact me at
http://www.derekfountain.org : <a
href="http://www.derekfountain.org/">Derek Fountain</a>
Jul 17 '05 #1
1 7374
Derek Fountain wrote:
<snip>
Removing the session_destroy() allows things to work, but leaves traces in the file in the temp directory. See the comment by licp at
http://au2.php.net/manual/en/functio...enerate-id.php. The post on that page by chris appears to do what I want but he uses a
session_close() function which doesn't exist (at least not in PHP 4.3.4 which is what I'm using on SUSE Linux).


Sounds like a typo for session_write_close()
<http://in.php.net/session_write_close>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #2

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

Similar topics

3
by: Pete | last post by:
I have a site which is using sessions to pass data from one page through to the next. The problem that I have is that there are only two places where the session could/should be destroyed. This...
27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
1
by: mudge | last post by:
I'm running PHP Version 4.3.10. I'm trying to make it so that when a person logs in using a user name and password that their session is valid and continues for a few months so they don't have to...
4
by: megha | last post by:
Hi I am writing a program in JSP which requires user to log in and as he logs in database was updated with his status on and till the user does not sign out no other user with same login and...
7
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...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
6
by: somaskarthic | last post by:
Hi This is somas here. I asked query about detecting the browser close event using javascript. I want to detect the event only when the X button in the top right corner is clicked and not else...
4
by: ddolgoff | last post by:
Hello to everyone, I have a problem of managing a session with cookies and "session_set_save_handler()". I want to use php's built-in session management mechanism with user-level session storage...
3
dlite922
by: dlite922 | last post by:
Hey guys, My brains asleep and I don't know what's wrong with my session class. I'm over riding session with sesstion_set_save_handler() in a class; When in my member functions (open,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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 project—planning, coding, testing,...

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.