Jump to content



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