TapeGun007 Posted June 22, 2010 Share Posted June 22, 2010 Ok, so I used to have my website located on an IP address while it was in development. Then I transferred the domain over to the new host. This used to clear all the cookies no problem, now it does not. If (isset($_GET["logout"])) { setcookie('Active','',time()-3600); setcookie("MemberID","",time()-3600); setcookie("FirstName","",time()-3600); setcookie("LastName","",time()-3600); setcookie("Admin","",time()-3600); setcookie("SuperAdmin","",time()-3600); setcookie("Admin_Rights","",time()-3600); // echo '<META HTTP-EQUIV="Refresh" Content="0; URL=login.php">'; echo $_COOKIE['Active']."<br>"; echo $_COOKIE['MemberID']."<br>"; echo $_COOKIE['FirstName']."<br>"; echo $_COOKIE['LastName']."<br>"; echo $_COOKIE['Admin']."<br>"; echo $_COOKIE['SuperAdmin']."<br>"; echo $_COOKIE['Admin_Rights']."<br>"; exit; } The result is that these echo statement return values of the cookies under the domain name. However, if I go back and load this website through the IP address, they work just fine. I have tried to clear out the MSIE 8 cache and such, and restarting it, but it still continues to fail, but only if I load the website via the domain. Why? Quote Link to comment https://forums.phpfreaks.com/topic/205498-weird-cant-clear-cookies/ Share on other sites More sharing options...
Alex Posted June 22, 2010 Share Posted June 22, 2010 To understand why this happens you have to understand how cookies are sent to the server. Cookies are sent to the server only in the HTTP headers at the beginning of a HTTP request. Meaning that no matter what you do to the cookies during the script you won't notice a change until the next time the updated cookies are sent back to the server, which is on the next request. Quote Link to comment https://forums.phpfreaks.com/topic/205498-weird-cant-clear-cookies/#findComment-1075370 Share on other sites More sharing options...
TapeGun007 Posted June 22, 2010 Author Share Posted June 22, 2010 Thank you Alex for the reply. Why does this happen only in MSIE and not Firefox or Chrome then? And how can I fix this in IE specifically? Quote Link to comment https://forums.phpfreaks.com/topic/205498-weird-cant-clear-cookies/#findComment-1075640 Share on other sites More sharing options...
Alex Posted June 22, 2010 Share Posted June 22, 2010 Cookies are domain specific. If you set them using the domain, then use the ip address to access the website to see if they're being cleared it's only giving you the illusion that they're being cleared on the same request because they were never set. That's my best guess at least, I'm not entirely sure I understand your situation. Quote Link to comment https://forums.phpfreaks.com/topic/205498-weird-cant-clear-cookies/#findComment-1075651 Share on other sites More sharing options...
TapeGun007 Posted June 23, 2010 Author Share Posted June 23, 2010 Well... I discovered that using: header('Location:login.php'); Works and using echo '<META HTTP-EQUIV="Refresh" Content="0; URL=login.php">'; does not. For whatever reason, the META will not clear out the info and reset the cookies, but the header will. Which I'm assuming this goes back to what you were saying earlier about how cookies actually operate. Quote Link to comment https://forums.phpfreaks.com/topic/205498-weird-cant-clear-cookies/#findComment-1075894 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.