javascript javascript可以删除http头设置的cookie吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15407475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 00:41:02  来源:igfitidea点击:

Can javascript delete a cookie set by http header?

javascripthttpcookies

提问by HOT.CHO

I try to delete cookie set by http header but doesn't work. What's the different between http-set cookie and javascript-set cookie ?

我尝试删除由 http 标头设置的 cookie,但不起作用。http-set cookie 和 javascript-set cookie 有什么不同?

回答by penguat

Yes, javascript can delete a cookie set by HTTP headers unless it is specifically a HTTPOnlycookie.

是的,javascript 可以删除由 HTTP 标头设置的 cookie,除非它特别是HTTPOnlycookie。

The cookie must also be from the same domain as the javascript.

cookie 还必须来自与 javascript 相同的域。

See also http://www.quirksmode.org/js/cookies.htmland Clearing all cookies with JavaScript

另请参阅http://www.quirksmode.org/js/cookies.html使用 JavaScript 清除所有 cookie