开发者

deleting duplicate cookie on domain

开发者 https://www.devze.com 2023-04-02 02:41 出处:网络
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

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"
0

精彩评论

暂无评论...
验证码 换一张
取 消