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 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 MATLAB四叉树处理长方形tif文件
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 使用Java milo连接Kepserver服务端报错?
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了