note 48853 added to function.session-destroy
| From: | nbehihATgmxdottnett at osu1 dot php dot net | Date: | Sun, 09 Jan 2005 13:57:09 +0000 |
| Subject: | note 48853 added to function.session-destroy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82983@lists.php.net to get a copy of this message | ||
If you want to keep your session_id() unchanged, but you want to reset all session variables, BEWARE
of unset($_SESSION). Doing so, and setting session variables (like $_SESSION['test'])
afterwards has the effect, that your changes will not be saved at the end of your script (not even
with session_write_close()).
So you better code like this:
foreach ($_SESSION as $VarName => $Value) {
unset ($_SESSION[$VarName]);
}
$_SESSION['test'] = 'MyTestValue';
----
Manual Page -- http://www.php.net/manual/en/function.session-destroy.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48853
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48853&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48853&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48853&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48853&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48853&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48853&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48853&report=yes
Search -- http://master.php.net/manage/user-notes.php