Hi,
I've been asked to look at some code, after the original programmer left. The code is from a login/logout page, but for some reason logout is not working. Code is below. The trouble with the page is that when you click on the logout link, 'login.php?action=logout' the message 'You are already logged in' pops up, and doesn't actually logout.
I thought it was something to do with the '&& empty($HTTP_GET_VARS)' but I've removed this, and it stills fails to logout.
Can anyone suggest why its failing?
Many thanks
Ben
// User authentication
if($user['logged_in'] && empty($HTTP_GET_VARS))
{
// If user logged in, show message & redirect to index
die(dialog("You are already logged in.",
$page_title, "Index", "index.php", true, true));
}
//
// User logs out ----------------------------------------------------------------------------------------------------
//
if($_GET['action'] == "logout")
{
//
// Check if user logged in, if not show error
//
if(!$user['logged_in'])
{
die(dialog("You are not logged in.", $page_title, "Index", "index.php", true, true));
}
else
{
setcookie("userdata", "", time()-36000);
die(dialog("You are now logged out.", $page_title, "Log In", "login.php", true, true));
}
}