我不是要尝试使用 xmlhttprequest 发送 cookie 数据,而是尝试使用 xmlhttprequest 为 session 设置 cookie,而无需用户交互。
最佳答案
根据spec :
If the user agent supports HTTP State Management it should persist, discard and send cookies (as received in the Set-Cookie and Set-Cookie2 response headers, and sent in the Cookie header) as applicable.
据我所知,Firefox 3.6 将存储 cookie,但它们将无法用于通过
document.cookie
执行查询的页面的文档。 .但是它们会与后续的 XMXHttpRequests 一起发送,这对于我的使用来说已经足够了。
关于cookies - 如果有来自 xmlhttprequest 的 set-cookie 响应,浏览器是否会接受它并设置 cookie?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1174206/