gpt4 book ai didi

javascript - 为什么有些cookie无法从document.cookie中获取?

转载 作者:行者123 更新时间:2023-12-03 01:26:08 26 4
gpt4 key购买 nike

我正在使用document.cookie去获取网站的cookie值,但它无法获取所有cookie值。示例 session cookie sid,我可以在 Google Chrome Cookie 管理器中看到它,但无法通过 javascript 获取值。

如何通过 javascript 设置 cookie,但它不会显示在 document.cookie 中(仍然在请求 header 中将这些值发送到服务器)?

最佳答案

从github复制的答案:https://github.com/expressjs/session/issues/274#issuecomment-185308426

Your cookie is likely set to httponly: true. This is the default value. If you, or anyone else reading this doesn't already know, it can be unnecessary and a bad decision to set this value to false. Search for "httponly cookie" and you'll find some good explanations of why you wouldn't want Javascript to have access to cookies.

关于javascript - 为什么有些cookie无法从document.cookie中获取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51531451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com