[英]Can't set cookie for “cloudfront.net” in Chrome?
Today I found a weird thing: it seems that Chrome(46.0) set some restrictions for specific URL such as cloudfront.net
. 今天,我发现了一件奇怪的事情:Chrome(46.0)似乎为特定URL(例如
cloudfront.net
)设置了一些限制。
It can be reproduced like this: 可以这样复制:
In the /etc/hosts
, add two lines: 在
/etc/hosts
,添加两行:
127.0.0.1 cloudfront.net 127.0.0.1 cloudfront.net
127.0.0.1 cloudfront.com 127.0.0.1 cloudfront.com
Start Apache or Nginx for the local server 为本地服务器启动Apache或Nginx
Open chrome and input cloudfront.net
in the address bar 打开chrome并在地址栏中输入
cloudfront.net
Run the following statement in the console: 在控制台中运行以下语句:
document.cookie = "test=test; expires=Thu, 01 Jan 2020 00:00:00 GMT;domain=cloudfront.com; path=/" document.cookie =“ test = test; expires = Thu,2020年1月1日星期四00:00:00 GMT; domain = cloudfront.com; path = /”
And then 接着
console.log(document.cookie) 执行console.log(document.cookie中)
As can be seen the document.cookie
is empty, it is not set at all, which is weird (See the screenshot below) 可以看到
document.cookie
为空,根本没有设置,这很奇怪(请参见下面的屏幕截图)
However, when I repeat the steps above but change the URL from cloudfront.net
into cloudfront.com
, everything works well like a magic.. (See the screenshot below) 但是,当我重复上述步骤,但将URL从
cloudfront.net
更改为cloudfront.com
,一切运行起来就像魔术一样。(请参阅下面的屏幕截图)
Does anyone have any ideas about this? 有人对此有任何想法吗? Thanks!
谢谢!
I asked the question in Google Group ( https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/Hs1838k68bw/z_h4EHVwAAAJ ) . 我在Google网上论坛( https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/Hs1838k68bw/z_h4EHVwAAAJ )中问了这个问题。 It looks that Chrome indeed set some restrictions for some sites:
Chrome似乎确实对某些网站设置了一些限制:
https://groups.google.com/a/chromium.org/d/msg/chromium-dev/Hs1838k68bw/z_h4EHVwAAAJ https://groups.google.com/a/chromium.org/d/msg/chromium-dev/Hs1838k68bw/z_h4EHVwAAAJ
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.