1
<?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, "/");
    }

?>

以上是我的注销代码。但是会话变量没有被删除。

4

3 回答 3

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();
?>

该示例就在页面http://php.net/manual/en/function.session-destroy.php上

于 2012-10-26T18:55:14.447 回答
-1

放在声明session_destroy();之后if。您不想在创建会话后立即销毁它...

编辑:您的代码令人困惑。你在说什么会话变量?我没有看到。

于 2012-10-26T18:43:23.627 回答
-1
setcookie ("TestCookie", "", time() - 3600);

php.net/manual/en/function.setcookie.php

Example #2 setcookie() 删除示例

于 2012-10-26T18:53:07.517 回答