dtt5830659
2014-02-04 10:21
浏览 11
已采纳

过期cookie文件

My website is behaving the way I want it to... I have to run my logout script twice before I'm completely signed out.

From what I can tell (from doing get_defined_vars() and printing the result) The first time i run the script it destroys the session, but doesn't expire the cookies. Here is my logout.php:

<?php
session_start();
// Set Session data to an empty array
$_SESSION = array();
// Expire their cookie files
if(isset($_COOKIE["id"]) && isset($_COOKIE["user"]) && isset($_COOKIE["pass"])) {
    setcookie("id", '', strtotime( '-50 days' ), '/');
    setcookie("user", '', strtotime( '-50 days' ), '/');
    setcookie("pass", '', strtotime( '-50 days' ), '/');
}
// Destroy the session variables
session_destroy();
// Double check to see if their sessions exists
if(isset($_SESSION['username'])){
header("location: message.php?msg=Error:_Logout_Failed");
} else {
    header("location: http://www.kokarma.com");
    exit();
} 
?>

What is wrong with my script?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dsa5211314 2014-02-04 10:38
    最佳回答
       setcookie("id", '',time()-100);
        setcookie("user", '',time()-100);
        setcookie("pass", '', time()-100);
    

    Try this.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题