Got it from php.net, but I am not sure is this how everybody destroy all sessions?
// Unset all Sessions
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() -42000, '/');
}
session_destroy();
Does the code will destroy all the sessions?? Is it the most common way? how do you guys destroy php sessions?
Oh yeah, btw, what is that session_name()
? All session name? e.g $_SESSION['var1']
, $_SESSION['var2']
, ... ?
I dont need to use unset($_SESSION['var1']);
any more right?
Whats the different between using session_destroy()
and unset($_SESSION[])
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…