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
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");
	}
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.