marcus Posted October 27, 2007 Share Posted October 27, 2007 Ok. What I'm doing is checking to see whether the UID and Encrypted Password combination is correct. if($need_log > 0){ $sql = "SELECT * FROM `users` WHERE `id`='{$_COOKIE['uid']}' AND `password`='{$_COOKIE['cpp']}'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) == 0){ setcookie("uid","",time()-314496000); setcookie("cp","",time()-314496000); setcookie("cpp","",time()-314496000); unset($_COOKIE); header("Location: /index.php"); } } It does redirect the user to the index but the cookies remain unchanged and have the same values in the end. That's the exact code I have when the user wants to log out, and that works, but the code checked here does not work. Quote Link to comment https://forums.phpfreaks.com/topic/75019-cookies-will-not-delete/ Share on other sites More sharing options...
kael.shipman Posted October 27, 2007 Share Posted October 27, 2007 Is this code being executed from a different path? I know cookies are pretty sensitive, so if you set them in /subpath/subpath2, then try to delete them from root or /subpath, it may not work. If you're not setting the path parameters explicitly when the cookie is created, try doing that, then stating the same parameters when you delete them. If that doesn't work, I don't have any idea what the problem might be. It seems strange that the deletion works on logout but not there. Quote Link to comment https://forums.phpfreaks.com/topic/75019-cookies-will-not-delete/#findComment-379341 Share on other sites More sharing options...
marcus Posted October 27, 2007 Author Share Posted October 27, 2007 The path for the cookies are set to "/" Quote Link to comment https://forums.phpfreaks.com/topic/75019-cookies-will-not-delete/#findComment-379342 Share on other sites More sharing options...
kael.shipman Posted October 27, 2007 Share Posted October 27, 2007 Hm. So you're setting the cookies with setcookie("uid", [id], time() + 60*60*24*365, "/"). Did you try deleting it with setcookie("uid", "", time() - 3600, "/")? I didn't pick up from your post whether or not you're operating in the same path with both calls to setcookie(). That would certainly make a difference. Quote Link to comment https://forums.phpfreaks.com/topic/75019-cookies-will-not-delete/#findComment-379355 Share on other sites More sharing options...
marcus Posted October 27, 2007 Author Share Posted October 27, 2007 Um, it's set as "/" by default. Well I have: domains.com/logout.php and domains.com/forums/index.php Quote Link to comment https://forums.phpfreaks.com/topic/75019-cookies-will-not-delete/#findComment-379374 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.