Jump to content

Cookies


themistral

Recommended Posts

Hi guys,

 

I am having a sticky problem with Cookies.

Basically, I've had to change the settings of my CMS which has resulted in me now having the same cookie names for the cookie domains .domain.com and www.domain.com.

 

I know I can just clear my cookies and the problem will be sorted, but it's not feasible for me to expect users of my site to clear their cookies.

 

So my question is this.

How can I delete the cookies created using www.domain.com with PHP?

Everytime I set the expiry date of the cookies, it only applies it to those on .domain.com.

 

Any help would be gratefully appreciated!!

Link to comment
Share on other sites

You'll need to be more specific, but if you want to control what domains the cookies are used on, use session_set_cookie_params() or setcookie() to specify.  If you want example.com and www.example.com to be different then don't use (notice the . ) .example.com as this applies to all subdomains of example.com.

Link to comment
Share on other sites

Please guys,

 

Can this even be done?

Everytime I set the cookies to expire in the past, it only clears the cookies from .domain.com - the cookies for www.domain.com are left.

 

$expiry = time()-10000;
foreach ($_COOKIE as $key => $value) {	
	setcookie($key, '', $expiry, '/', '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.