note 17236 deleted from function.session-destroy by jimw
| From: | jimw@php.net | Date: | Fri, 07 Dec 2001 00:47:12 +0000 |
| Subject: | note 17236 deleted from function.session-destroy by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-21741@lists.php.net to get a copy of this message | ||
The above example requires you (at least in Win2k) to give read/write permission to your sessions
directory:
unlink(session_save_path().'/sess_'.$PHPSESSID);
setcookie('PHPSESSID','',time()-3600,'/');
You can achieve the same without setting the permissions using:
session_destroy();
setcookie('PHPSESSID','',time()-3600,'/');
There is no need to unset all your variables either (as some above posts suggested) unless you want
to make sure they disappear immediatly; instead of at the end of the page scope. You can also
achieve the same by simply adding to the above:
if (isset($name_of_any_previous_session)&&endless!="1") {
header("Location: ".$PHP_SELF."?endless=1");
//endless is just protection against an endless loop in the case the session just won't die
}