note 69609 deleted from function.session-destroy by bjori

From: Date: Tue, 05 Dec 2006 12:17:15 +0000
Subject: note 69609 deleted from function.session-destroy by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-120292@lists.php.net to get a copy of this message
Note Submitter: webmaster at unitedscripters dot com ---- 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.

« previous php.notes (#120292) next »