删除域上重复的 cookie
我正在尝试从网站中删除 cookie 条目。问题是,当 cookie 注册时,它会在网站的 www.domainname.com
和 .domainname.com
上注册,因此有两个条目。我正在尝试使用以下方法删除 cookie:
jQuery.cookie("cookie","",{expires:-5,domain:".domainname.com"});
jQuery.cookie("cookie","",{expires:-5,domain:"www.domainname.com"});
尝试捕获两者。但是,其中之一始终保留,并且不会被删除/过期。无论如何强制cookie过期?我也可以访问 PHP。
i'm trying to delete 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有权访问 php,则可以使用 setcookie 函数删除 cookie:setcookie php。
对你来说重要的第五个参数 - 域。
If you have access to php you can delete cookie with setcookie function: setcookie php.
For you is important fifth argument - domain.
我知道这已经太晚了,但我在尝试设置谷歌翻译 cookie 时遇到了同样的问题。
这最终起作用了:
I know this is super late, but I just had the same problem trying to set the google translate cookie.
This ended up working: