Chrome localhost cookie 未设置

编程入门 行业动态 更新时间:2024-10-28 20:16:33
本文介绍了Chrome localhost cookie 未设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 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 未设置

本文发布于:2023-10-29 17:15:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1540293.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Chrome   localhost   cookie

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!