document.cookie不存储cookie? [英] document.cookie not storing cookie?

查看:725
本文介绍了document.cookie不存储cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

document.cookie只能在服务器上工作吗?警告似乎没有输出我的Cookie。

  document.cookie =d = e; 
alert(document.cookie);


解决方案

某些浏览器在文档



Chrome Chrome故意禁用cookie
on文件://,由于各种原因。
当我们写我们的cookie支持时,
正确的行为是不清楚的,当
处理文件共享。
我们发现文件中的cookie://是
相当不常见,它有几个
负面的安全隐患。



可以使用
命令行标志
--enable-file-cookies。



Cookie是严格的一个HTTP
机制,根据RFC 2109.有
应该是没有合理的期望
他们为协议工作其他
比HTTP,更少的文件:///,和
不清楚他们的行为
应该是什么,以及什么安全规则
分区应该应用。


来源


Does document.cookie only work on a server? Alert doesn't seem to be outputting my cookie.

document.cookie = "d=e";
alert(document.cookie);

解决方案

Some browsers won't honor cookies when set by a document with the file protocol.

Chrome intentionally disables cookies on file://, for a variety of reasons. When we wrote our cookie support, the correct behavior was unclear when dealing with things like file shares. We found cookies on file:// to be fairly uncommon, and it has a few negative security implications.

You can, however, enable them with the command line flag --enable-file-cookies.

Cookies are strictly a HTTP mechanism as per RFC 2109. There should be no reasonable expectation for them to work for protocols other than HTTP, much less file:///, and it is not clear what their behavior should be, and what rules of security compartmentalization should apply.

Source.

这篇关于document.cookie不存储cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆