themistral Posted December 7, 2010 Share Posted December 7, 2010 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!! Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 7, 2010 Share Posted December 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
themistral Posted December 7, 2010 Author Share Posted December 7, 2010 Hi, The problem is that I have $_COOKIE[foobar] set in .domain.com but also have $_COOKIE[foobar] set in www.domain.com]. The one in .domain.com is correct, but I don't seem to be able to access the cookie set to www.domain.com. Quote Link to comment Share on other sites More sharing options...
themistral Posted December 9, 2010 Author Share Posted December 9, 2010 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'); } Quote Link to comment 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.