evanct Posted June 5, 2009 Share Posted June 5, 2009 So when user logs in, cookie is set in loggedin.php: <?php $id=$_GET['id']; setcookie('login',$id,time()+7200,'/'); header('location:index.php'); ?> Then when the user logs out, as part of the logout function(which otherwise works) the cookie is allegedly unset: setcookie ('login', '', time() - 7200); It then redirects to index.php, where if $_COOKIE['login'] is not set it will redirect to login.php. it doesn't redirect. print_r($_COOKIE) reveals that $_COOKIE['login'] is in fact still set to the value it was set to in loggedin.php. What's going on? Link to comment https://forums.phpfreaks.com/topic/161012-solved-unsetting-cookie-does-not-work/ Share on other sites More sharing options...
btherl Posted June 5, 2009 Share Posted June 5, 2009 Can you try setting the path argument ("/") when you unset the cookie? Link to comment https://forums.phpfreaks.com/topic/161012-solved-unsetting-cookie-does-not-work/#findComment-849719 Share on other sites More sharing options...
evanct Posted June 5, 2009 Author Share Posted June 5, 2009 Yeah that fixed it. should have tried that myself, didn't think it would make a difference. thanks. Link to comment https://forums.phpfreaks.com/topic/161012-solved-unsetting-cookie-does-not-work/#findComment-849720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.