issue with session across subdomain only for googl

2019-09-08 06:57发布

问题:

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

回答1:

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 the b site is setting b.mydomain.com, prevent the cookie from appear on site a.



回答2:

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



回答3:

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.