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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?