note 12652 deleted from function.session-destroy by jimw

From: Date: Fri, 07 Dec 2001 00:46:12 +0000
Subject: note 12652 deleted from function.session-destroy by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-21736@lists.php.net to get a copy of this message
it seems that sessions react unpredictably sometimes, so you've really got to spell it out to destroy one. just ensure session_start() is called at the top of each script and use something like this to destroy it.. function session_clear() { // if session exists, unregister all variables that exist and destroy session $exists = "no"; $session_array = explode(";",session_encode()); for ($x = 0; $x < count($session_array); $x++) { $name = substr($session_array[$x], 0, strpos($session_array[$x], "|")); if (session_is_registered($name)) { session_unregister('$name'); $exists = "yes"; } } if ($exists != "no") { session_destroy(); } } simon http://www.studio24.net

« previous php.notes (#21736) next »