Chrome localhost cookie 未设置

Chrome localhost cookie not being set(Chrome localhost cookie 未设置)

本文介绍了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 未设置

基础教程推荐