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.

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

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失