Hello all. I have modifed the article from here on user authentication to include cookies so the user does not have to log in each visit of the site. The problem is, I can't figure out how to let them logout. Here is the source code of the two files.
auth.php (included in each file)
logout.phpPHP Code:<?
session_start();
$uid = isset($_COOKIE['uid']) ? $_COOKIE['uid'] : $_SESSION['uid'];
$pwd = isset($_COOKIE['pwd']) ? $_COOKIE['pwd'] : $_SESSION['pwd'];
$_SESSION['uid'] = $uid;
$_SESSION['pwd'] = $pwd;
$sql = "SELECT * FROM info WHERE charname = '$uid' AND pass = '$pwd'";
$result = mysql_query($sql);
$r = mysql_fetch_array($result);
$pre = $r["premium"];
if (!$result) {
echo "A database error occurred while checking your login details!";
echo mainFooter();
exit;
}
?>
After the logout file redirects me to the homepage, it shows i am still logged in.PHP Code:<?
session_start();
session_unregister('uid');
session_unregister('pwd');
setcookie ("uid", "", mktime(12,0,0,1, 1, 1990));
setcookie ("pwd", "", mktime(12,0,0,1, 1, 1990));
session_destroy();
unset($uid);
unset($pwd);
header("Location: http://www.eqsig.com");
?>





Bookmarks