Session close, destroy and regenerate

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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['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 . 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 : <a
href=" /">Derek Fountain</a>

Re: Session close, destroy and regenerate

Derek Fountain wrote:
Quoted text here. Click to load it
traces in

Sounds like a typo for session_write_close()

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

Site Timeline