immanuelx2 Posted June 18, 2007 Share Posted June 18, 2007 login.php: setcookie('id', $userinfo['id'], time()+60*60*24*31*3 , '/'); logout.php: setcookie('id', '', time()-60*60*24*2); Any idea why it is not deleting my cookie? Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/ Share on other sites More sharing options...
per1os Posted June 18, 2007 Share Posted June 18, 2007 <?php setcookie('id', '', time()-60*60*24*2), '/'); unset($_COOKIE['id']); // for good measure Try that. Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-276887 Share on other sites More sharing options...
immanuelx2 Posted June 18, 2007 Author Share Posted June 18, 2007 nice Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-276888 Share on other sites More sharing options...
immanuelx2 Posted June 18, 2007 Author Share Posted June 18, 2007 weird, it worked the first time, but now it still doesn't log me out... login.php: <?php setcookie('id', $userinfo['id'], time()+60*60*24*31*3 , '/'); header("Location: " . $_POST['redirect']); ?> logout.php <?php setcookie('id', '', time()-60*60*24*2); unset($_COOKIE['id']); header("Location: ".$_POST['redirect']); exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-276905 Share on other sites More sharing options...
per1os Posted June 18, 2007 Share Posted June 18, 2007 Sometimes the header tag does not run well with sessions and cookies try this instead: logout.php <?php setcookie('id', '', time()-60*60*24*2); unset($_COOKIE['id']); echo '<script type=text/javascript>location.href="' . $_POST['redirect'] . '";</script>'; //header("Location: ".$_POST['redirect']); exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-276922 Share on other sites More sharing options...
immanuelx2 Posted June 19, 2007 Author Share Posted June 19, 2007 Sometimes the header tag does not run well with sessions and cookies try this instead: logout.php <?php setcookie('id', '', time()-60*60*24*2); unset($_COOKIE['id']); echo '<script type=text/javascript>location.href="' . $_POST['redirect'] . '";</script>'; //header("Location: ".$_POST['redirect']); exit; ?> boo why don't they fix that? that Jscript creates a back button circle Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-277296 Share on other sites More sharing options...
immanuelx2 Posted June 19, 2007 Author Share Posted June 19, 2007 why does this not work.... setcookie('id', '', time()-60*60*24*2); unset($_COOKIE['id']); echo '<meta http-equiv="refresh" content="5; url='.$_POST['redirect'].'">'; require 'header.php'; echo 'You are now logged out! Redirecting...'; everything displays correctly but.. that damn cookie is still there Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-277361 Share on other sites More sharing options...
teng84 Posted June 19, 2007 Share Posted June 19, 2007 setcookie("name", "", -1); use this to destroy cookie instead of unset Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-277365 Share on other sites More sharing options...
immanuelx2 Posted June 19, 2007 Author Share Posted June 19, 2007 i figured out what it was i had to inclue the '/' field in the second time around... Quote Link to comment https://forums.phpfreaks.com/topic/56067-solved-cookie-not-deleting/#findComment-277387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.