i'm trying to d开发者_运维知识库elete a cookie entry from a site. the problem is, when the cookie is registered, it registers on both the www.domainname.com
and .domainname.com
of the site, so there is two entries. I am trying to delete the cookie using:
jQuery.cookie("cookie","",{expires:-5,domain:".domainname.com"});
jQuery.cookie("cookie","",{expires:-5,domain:"www.domainname.com"});
to try and catch both. however, one or the other always stays, and will not get deleted/expired. Anyway to force the cookie to expire? I have access to PHP as well.
If you have access to php you can delete cookie with setcookie function: setcookie php. For you is important fifth argument - domain.
I know this is super late, but I just had the same problem trying to set the google translate cookie.
This ended up working:
jQuery.cookie("cookie", null, { path: "/",domain: ".domainname.com" });
jQuery.cookie("cookie", null, { path: "/" }); //sets domain:"www.domainname.com"
精彩评论