note 69532 added to function.session-destroy
| From: | webmaster at unitedscripters dot com | Date: | Sat, 09 Sep 2006 00:45:18 +0000 |
| Subject: | note 69532 added to function.session-destroy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116948@lists.php.net to get a copy of this message | ||
Please note that any advice to destroy a session via a command like:
$_SESSION = array();
may lead to a catastrophe particularly if there is enough clout on it to induce you into believing
that must be quite sound an advice - meaning with catastrophe endless nights trying to debug
something elusive, because you thought that advice was authoritative.
In fact, the correct way should be:
$_SESSION=null; /*NULL, not array() !*/
The issue may be as follows: in order to reset the session you use $_SESSION=array() and then you
call on other stuff - well, the session still EXISTS as an array, and since your other lines of
codes are doing the right thing namely verifying whether (!$_SESSION), that checks invariably
fails..
If for any reason you are going to reset a session using an assignement, consider using =NULL.
----
Server IP: 80.241.173.254
Probable Submitter: 84.221.75.209
----
Manual Page -- http://www.php.net/manual/en/function.session-destroy.php
Edit -- https://master.php.net/note/edit/69532
Del: integrated -- https://master.php.net/note/delete/69532/integrated
Del: useless -- https://master.php.net/note/delete/69532/useless
Del: bad code -- https://master.php.net/note/delete/69532/bad+code
Del: spam -- https://master.php.net/note/delete/69532/spam
Del: non-english -- https://master.php.net/note/delete/69532/non-english
Del: in docs -- https://master.php.net/note/delete/69532/in+docs
Del: other reasons-- https://master.php.net/note/delete/69532
Reject -- https://master.php.net/note/reject/69532
Search -- https://master.php.net/manage/user-notes.php