我有一个 ASP 应用程序,它使用 cookie 来存储用户选择的语言.一切正常,除非我在本地主机上.将 localhost 替换为 127.0.0.1 使其再次工作......为什么?
I have an ASP application that uses a cookie to store the user selected language. Everything works fine except when I'm on localhost. Replacing localhost by 127.0.0.1 makes it work again... why?
我看到了对 file://的预期限制,但实际上我找不到任何对 localhost 的预期限制的参考.
I saw intended restrictions to file:// but I can't actually find any reference to intended restriction to localhost.
我无法真正理解的是,为什么 ASP 会话 (ASP.NET_SessionId) 和 ASP 表单身份验证 Cookie (.FSAUTHSSO) 正确设置为 localhost 域,但我的 cookie 没有......为什么?!
What I can't really understand is why the ASP Session (ASP.NET_SessionId) and ASP Forms Authentication Cookies (.FSAUTHSSO) are correctly set for the localhost domain but my cookies aren't... why?!
我已经用谷歌搜索了很多,但没有任何效果:
I already googled a lot and nothing works:
- 设置 Chrome 命令行标志 --enable-file-cookies [不要工作]
- 将 cookie 设置为 HttpOnly [DOESN'T MATTER]
- 将过期时间更改为会话或日期...[不重要]
- 将 Cookie 路径更改为根目录 (/) 或其他任何内容 [DOESN'T MATTER]
那么重要的是什么?:)
So what does matter? :)
为什么可以设置 ASP cookie 而我的却不能?有什么区别?
And why can the ASP cookies be set and mine don't? What's the difference?
最后要提一下,这也发生在 IE 上,但在 FF 上运行良好.
Last thing just to mention that this also happens on IE but works fine on FF.
谢谢!
亚历克斯
推荐答案Cookies 是为二级及以下设计的.一级域将不起作用.相反,您应该使用地址 127.0.0.1 (如您所述),或者您可以编辑您的主机文件以映射具有 TLD 的不同 URL 到地址 127.0.0.1,例如:
Cookies are designed for second level and down. First level domains will not work. Instead you should use the address 127.0.0.1 (as you mentioned) or you could edit your hosts file to map a different URL with a TLD to the address 127.0.0.1 such as:
yoursite.tld 127.0.0.1刚刚对此进行了进一步研究;找到了这个答案:本地主机上具有显式域的Cookies
Just researched this further; found this answer: Cookies on localhost with explicit domain
更多推荐
Chrome localhost cookie 未设置
发布评论