Jump to content

Can't destroy cookies in IE8


themistral

Recommended Posts

Hi guys,

 

I'm having a problem with destroying Cookies in IE8 (maybe other versions of IE but this is the one I'm testing on).

 

I am checking to see if the referrer of the site is not itself, and if not, delete all cookies with the cookie domain.

 

if ($_COOKIE['exp_last_visit'] < mktime("23", "59", "59", "12", "03", "2010")) {
if (!strstr($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
	foreach ($_COOKIE as $key => $value) {
		setcookie($key, $value, time()-10000, "/", ".domain.com");
	}
}
}

 

This works in Chrome and FF, but of course, not IE8.

If anyone could shed any light on this I'd be really grateful!

Link to comment
https://forums.phpfreaks.com/topic/220562-cant-destroy-cookies-in-ie8/
Share on other sites

I think I may have solved this...IE was storing the cookie with www.domain.com and that wasn't being deleted.

I now have the following code and it seems to be working.

 

if ($_COOKIE['exp_last_visit'] < mktime("23", "59", "59", "12", "03", "2010")) {
if (!strstr($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
	foreach ($_COOKIE as $key => $value) {
		setcookie($key, $value, time()-10000, "/", ".domain.com");
		setcookie($key, $value, time()-10000, "/", "www.domain.com");
	}
}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.