note 19198 added to function.session-destroy
| From: | steveua at yahoo dot com | Date: | Tue, 19 Feb 2002 16:17:48 +0000 |
| Subject: | note 19198 added to function.session-destroy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26798@lists.php.net to get a copy of this message | ||
session_destroy and friends are a bit recalcitrant at times; While (unsuccesfully ) attempting to
build a multi-session logout, I came across this code (I forget the original author - my apologies)
that really saved my sanity.
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();
}
}
session_clear();
--
http://www.php.net/manual/en/function.session-destroy.php
http://master.php.net/manage/user-notes.php?action=edit+19198
http://master.php.net/manage/user-notes.php?action=delete+19198
http://master.php.net/manage/user-notes.php?action=reject+19198