如何编辑安全cookie?
我见过一些网站,你无法使用 javascript 获取或编辑他们的 cookie(只能在浏览器工具中看到)。它们是什么类型的饼干?如何通过 javascript 编辑它们?
i've seen some websites that you cannot get or edit theirs cookie with javascript (just can be seen in browser tool). What kind of cookie are they? How to edit them via javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
他们使用 HTTPOnly cookie: http://www.codinghorror .com/blog/2008/08/protecting-your-cookies-httponly.html。它们既不能从 JavaScript 中检索也不能修改。换句话说,您的问题“如何通过 javascript 编辑它们?”的答案是:你不能。
They are using HTTPOnly cookies: http://www.codinghorror.com/blog/2008/08/protecting-your-cookies-httponly.html. They can be neither retrieved nor modified from JavaScript. In other words, the answer to your question "How to edit them via javascript?" is: you cannot.
我知道这个问题很老了,但这个答案可能对某些人有帮助。
您可以通过安装诸如 Cookie Editor 之类的插件来修改浏览器中的此类 Cookie https://addons.mozilla.org/fr/firefox/addon/cookie-editor/,并关闭该 cookie 的 httponly :
I know this question is very old, but this answer might be helpful to some one.
You can modify these kind of cookies in your browser by installing a plugin like
Cookie Editor
https://addons.mozilla.org/fr/firefox/addon/cookie-editor/, and turn off httponly for that cookie :document.cookie
)编辑它们。httpOnly
的目的不是防御客户端,因为最终 cookie 是存储在客户端上的文件,因此无法对客户端实施限制,但它是为了防御客户端 JavaScript,即简单术语文档。 cookie。
document.cookie
.The purpose of
httpOnly
is not to defend against client because ultimately cookies are files stored on client so cannot enforce restrictions on client but it is to protect against client-side JavaScript which is simple termsdocument.cookie
.