Question

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?

Was it helpful?

Solution

   setcookie("id", '',time()-100);
    setcookie("user", '',time()-100);
    setcookie("pass", '', time()-100);

Try this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top