仅适用于 google chrome 的跨子域会话问题
我遇到了一个奇怪的问题,仅适用于谷歌浏览器的跨子域会话。 我有两个子域 a.mydomain.com & b.mydomain.com。 如果我首先在浏览器上打开 a.mydomain.com然后打开 b.mydomain.com &从那里登录然后我无法在 a.mydomain.com 中获得会话。但如果我先从 b.mydomain.co 登录 &然后打开 a.mydomain.com 我在 a.mydomain.com 中获取会话。
我无法解决这个问题。请帮忙
I've faced a strange issue with session across subdomain only for google chrome.
I have two subdomain a.mydomain.com & b.mydomain.com.
if I open a.mydomain.com first on browser & then open b.mydomain.com & login from there then I'm not getting the session in a.mydomain.com. But if I login first from b.mydomain.co & then open a.mydomain.com I'm getting the session in a.mydomain.com.
I'm unable to solve this. Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
愚蠢的我,找到了答案,所以喜欢分享它,
我仅将 session.cookie_domain 用于 b.mydomain.com &不适用于 a.mydomain.com
silly me, found the answer so liked to share it
I used session.cookie_domain only for b.mydomain.com & not for a.mydomain.com
查看浏览器中的会话 cookie。它们的域设置是什么?可能您的网站有不同的 cookie 设置。其中
a
站点正在设置.mydomain.com
cookie,b
站点正在设置b.mydomain.com,防止 cookie 出现在网站
a
上。Look at the session cookies in your browser. What are the domain settings on them? Possibly your sites have different cookie settings. where the
a
site is setting a.mydomain.com
cookie, and theb
site is settingb.mydomain.com
, prevent the cookie from appear on sitea
.仅当在上一级域中设置 Cookie 时,Cookie 才会被继承。在 example.com 上设置 cookie 会将其继承到 www.example.com、foo.example.com 等。
在 www.example.com 上设置 cookie 不会向 foo.example.com 显示 cookie。
Cookies will only be inherited when setting them on the domain one level above. Setting the cookie on example.com will inherit it to www.example.com, foo.example.com, etc.
Setting a cookie on www.example.com will not show the cookie to foo.example.com.