Cookies always stay
Posted: Mon Dec 17, 2007 4:36 pm
Hey Guys, I have the following Code:
The first chunk is the logout script, which appears to working ok, I have $_COOKIE and $_SESSION print_r'd below, and after logout, both the cookie and session arrays are empty. The second chunk, is to establish whether or not the user clicked "remember me" when they logged in, if so, a cookie would have been created. Now, after the logout script has run, if I then go to a new page, all my Session and Cookie data has returned, which can only be possible by the second chunk above, but in order for it to run, $_COOKIE['abc'] has to be set, and I explicitly unset it in the logout script, so can anyone see why this would be happening?
Just tested in Firefox, and it looks to be an IE problem only somehow.
Thanks.
Code: Select all
if(isset($_POST['dothelogout'])){
unset($_SESSION['sessid']);
unset($_SESSION['hurley']);
unset($_SESSION['displayname']);
setcookie("abc", "", time()-3600);
setcookie("PHPSESSID", "", time()-3600);
unset($_COOKIE['abc']);
unset($_COOKIE['PHPSESSID']);
}
if (isset($_COOKIE['abc'])){
$checktheuser = $_COOKIE['abc'];
$result = mysql_query("SELECT * FROM clientDetails WHERE clientusername = '$checktheuser'");
while ($row = mysql_fetch_array($result)){
$theusername = $row['clientusername'];
$displayname = $row['businessname'];
$d2 = $row['firstname'];
}
$_SESSION['sessid'] = session_id();
$_SESSION['hurley'] = $theusername;
$_SESSION['displayname'] = $d2 . " (" . $displayname . ")";
setcookie("abc", $checktheuser, time()+1209600);
}Just tested in Firefox, and it looks to be an IE problem only somehow.
Thanks.