note 101789 added to function.session-regenerate-id
| From: | sietse dot au at gmail dot com | Date: | Tue, 11 Jan 2011 12:49:04 +0000 |
| Subject: | note 101789 added to function.session-regenerate-id | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175630@lists.php.net to get a copy of this message | ||
@ Ben Johnson
Your code works, but why are you doing so much more effort.
<?php
// initialize session data based on new or existing session id
session_start();
// get a new session id and delete the old associated session file (which is linked with the old
session id)
session_regenerate_id(true);
// free all variables in $_SESSION, the $_SESSION in the current script still exists, but the
associated session file is gone. The data in $_SESSION can not be retrieved anymore from the
filesystem.
session_unset();
?>
What we have here is:
A empty $_SESSION superglobal
A new id and a new associated session file
The old session associated file is deleted so if you change your session id to the old one and
initialize the data with session_start(), it just creates a new session associated file
----
Server IP: 69.147.83.197
Probable Submitter: 178.202.57.61
----
Manual Page -- http://www.php.net/manual/en/function.session-regenerate-id.php
Edit -- https://master.php.net/note/edit/101789
Del: integrated -- https://master.php.net/note/delete/101789/integrated
Del: useless -- https://master.php.net/note/delete/101789/useless
Del: bad code -- https://master.php.net/note/delete/101789/bad+code
Del: spam -- https://master.php.net/note/delete/101789/spam
Del: non-english -- https://master.php.net/note/delete/101789/non-english
Del: in docs -- https://master.php.net/note/delete/101789/in+docs
Del: other reasons-- https://master.php.net/note/delete/101789
Reject -- https://master.php.net/note/reject/101789
Search -- https://master.php.net/manage/user-notes.php