note 48853 deleted from function.session-destroy by bjori
| From: | bjori@php.net | Date: | Tue, 05 Dec 2006 12:19:39 +0000 |
| Subject: | note 48853 deleted from function.session-destroy by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-120295@lists.php.net to get a copy of this message | ||
Note Submitter: n beh ih AT gmx dott nett
----
[Editor's Note]
doing $_SESSION = array();
is faster/quicker and works aswell.
[/Note]
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';