<?php
session_start();
session_destroy();
if(isset($_COOKIE['cookemail_id']) && isset($_COOKIE['cookpassword']))
{
setcookie("cookemail_id", "", time()-60*60*24*100, "/");
setcookie("cookpassword", "", time()-60*60*24*100, "/");
setcookie("cooktype", "", time()-60*60*24*100, "/");
}
?>
以上是我的退出代码。但是会话变量没有被删除。
答案 0 :(得分:1)
<?php
session_start();
if (isset($_COOKIE['cookemail_id']) && isset($_COOKIE['cookpassword'])) {
setcookie("cookemail_id", "", time()-42000, "/");
setcookie("cookpassword", "", time()-42000, "/");
setcookie("cooktype", "", time()-42000, "/");
}
$_SESSION = array();
if (ini_get("session.use_cookies")) {
setcookie(session_name(), '', time() - 42000, '/');
}
session_destroy();
?>
上
答案 1 :(得分:-1)
将session_destroy();
放在if
语句后面。您不希望在创建会话后立即销毁会话...
编辑: 你的代码令人困惑。你在谈论什么会话变量?我没有看到任何。
答案 2 :(得分:-1)
setcookie ("TestCookie", "", time() - 3600);
请参阅php.net/manual/en/function.setcookie.php
示例#2 setcookie()删除示例