contra10 Posted March 5, 2009 Share Posted March 5, 2009 i can't kill my cookie set cookie in login // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); header <?php //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; } ... reference to logout.php echo "<a style='text-decoration:none' href='http://localhost/logout/logout.php'><FONT FACE='ariel' SIZE='2' color='#5f5f5f'>Logout</FONT></a>"; ?> logout.php <?php if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; } $past = time() - 3900; //this makes the time in the past to destroy the cookie setcookie(ID_my_site, $username, $past); setcookie(Key_my_site, $pass, $past); header("Location: http://localhost/"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/148118-solved-cant-kill-cookie/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2009 Share Posted March 5, 2009 Based on the paths in your logout link and in your header redirect, you need to set the path in the setcookie() (4th parameter) so that the cookie is available in all paths on your site. Quote Link to comment https://forums.phpfreaks.com/topic/148118-solved-cant-kill-cookie/#findComment-777509 Share on other sites More sharing options...
premiso Posted March 5, 2009 Share Posted March 5, 2009 setcookie('ID_my_site', false); setcookie('Key_my_site', false); Give that a try. Because setting a cookie with a value of FALSE will try to delete the cookie, you should not use boolean values. Instead, use 0 for FALSE and 1 for TRUE. setcookie EDIT: If that fails, follow PFMaBismAd instructions. Also you should set the past to be at least 1 year ago, due to timezone differences. Quote Link to comment https://forums.phpfreaks.com/topic/148118-solved-cant-kill-cookie/#findComment-777513 Share on other sites More sharing options...
contra10 Posted March 5, 2009 Author Share Posted March 5, 2009 thnks both worked Quote Link to comment https://forums.phpfreaks.com/topic/148118-solved-cant-kill-cookie/#findComment-777518 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.