Hey everyone,
I'm working on a site that's experiencing some cookie craziness. The site uses sessions and cookies to store user information, with the cookies used to automatically log the user in if they have visited within the last 30 days. I also have a number of admin accounts (at various administrator levels) that some users also have.
The problem is, when I log in to the site under one user or admin account, logout, and re-login under another user or admin account, the cookie retains the value of the originally logged-in account. Closing the browser doesn't work--the cookie's value doesn't change. I've tested this on multiple browsers so I don't think it's a browser issue.
This is the script to logout:
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
if (isset($_COOKIE['fullname'])) {
setcookie('fullname','',time()-42000,'/');
unset($_COOKIE['fullname']);
}
session_destroy();
}
and this is part of the login script that sets the cookie:
session_start();
if (isset($_SESSION['fullname']) ) {
setcookie('fullname',$_SESSION['fullname'],time()+60*60*24*30);
}
Any suggestions?