note 69532 rejected from function.session-destroy by betz

From: Date: Sun, 10 Sep 2006 10:12:33 +0000
Subject: note 69532 rejected from function.session-destroy by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116979@lists.php.net to get a copy of this message
Note Submitter: webmaster at unitedscripters dot com ---- 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.

« previous php.notes (#116979) next »