I'm setting a Cookie with the following code:(admin.php)
if ($_POST['stayLoggedIn'] == '1') {
setcookie("id", $row['id'], time() + 60*60*24*365);
}
header("Location: addtip.php");
I can't get the cookie to unset, I've searched the site and the following code should be correct but it's not working;(admin.php)
if (array_key_exists("logout", $_GET)) {
unset($_SESSION);
setcookie("id", "", time()-60*60);
$_COOKIE["id"] = "";
}
Testing the cookie has been unset using the following code on the "loggedinpage" which would return to the admin login page if cookie was unset (addtip.php)
session_start();
if (array_key_exists("id", $_COOKIE)) {
$_SESSION['id'] = $_COOKIE['id'];
}
if (array_key_exists("id", $_SESSION)) {
echo "<a href='admin.php?logout' class='btn btn-danger btn-logout'>Log Out</a>";
} else {
header("Location: admin.php");
}