note 69609 added to function.session-destroy
| From: | webmaster at unitedscripters dot com | Date: | Tue, 12 Sep 2006 17:11:16 +0000 |
| Subject: | note 69609 added to function.session-destroy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117070@lists.php.net to get a copy of this message | ||
If you unset a session superglobal by
$_SESSION=array()
Be warned, and this warning can't be stressed enough, that then ALL your checks for the
existence of a session are IMPLICITLY supposed to be checking with session_id (rush to the
documentation there, in case).
The native value of an uninitialized session is null ($_SESSION is the only superglobal that is NOT
by default an empty array): unsetting it to array exposes codes that are checking the existence of a
session via things like
if(isset($_SESSION)){}
to potential terrible consequences. The check would in fact appear in itself perfectly valid: a non
existant session IS null, and the check would succeed.
Yet, if you have reset by $_SESSION=array() THEN your conditional checks should be if session_id()
or you are exposed to things like:
$_SESSION=array();
session_destroy();
//several lines of code
if(isset($_SESSION)){$enter->deletePrivileges();}
If you areusing session=array(), you are supposed to use session_id and do not rely any longer on
the session carrying its native value of null.
Of course, alternative:
$_SESSION=null;
It is then presumed that you won't loop it. In all cases, something is presumed, and ought to
be said in whichever case.
----
Server IP: 213.92.11.19
Probable Submitter: 84.221.110.198
----
Manual Page -- http://www.php.net/manual/en/function.session-destroy.php
Edit -- https://master.php.net/note/edit/69609
Del: integrated -- https://master.php.net/note/delete/69609/integrated
Del: useless -- https://master.php.net/note/delete/69609/useless
Del: bad code -- https://master.php.net/note/delete/69609/bad+code
Del: spam -- https://master.php.net/note/delete/69609/spam
Del: non-english -- https://master.php.net/note/delete/69609/non-english
Del: in docs -- https://master.php.net/note/delete/69609/in+docs
Del: other reasons-- https://master.php.net/note/delete/69609
Reject -- https://master.php.net/note/reject/69609
Search -- https://master.php.net/manage/user-notes.php