Chrome localhost cookie not being set(Chrome localhost cookie 未设置)
问题描述
我有一个 ASP.net 应用程序,它使用 cookie 来存储用户选择的语言.一切正常,除非我在本地主机上.将 localhost 替换为 127.0.0.1 使其再次工作......为什么?
I have an ASP.net 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.net 会话 (ASP.NET_SessionId) 和 ASP.net 表单身份验证 Cookie (.FSAUTHSSO) 正确设置为 localhost 域,但我的 cookie 没有......为什么?!
What I can't really understand is why the ASP.net Session (ASP.NET_SessionId) and ASP.net 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.net cookie 而我的却不能?有什么区别?
And why can the ASP.net 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 是为二级及以下设计的.一级域将不起作用.相反,您应该使用地址 http://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 http://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 未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Chrome localhost cookie 未设置
基础教程推荐
- rabbitmq 的 REST API 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 XML 转换为通用列表 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01