Set session cookies for specific subdomains

旧街凉风 提交于 2019-12-08 16:33:16

问题


I have a website with multiple subdomains, which share a unique PHP session cookie to identify each user. I did this by simply adding session.cookie_domain = '.mydomain.com', however I'm wondering if it's possible to specify more than one subdomain, so that cookies will only get sent to, for example, www.mydomain.com and user.mydomain.com but won't in images.mydomain.com. Would this be possible?


回答1:


No, those would have to be 2 separate cookies.

You would have to create a sub-domain like sub.mydomain.com, have hosts like www.sub.mydomain.com etc., and set cookies for .sub.mydomain.com if you wanted to isolate cookies in that way...




回答2:


for future users, actually you can just rename the cookie id and you can have specific cookie for that subdomain



来源:https://stackoverflow.com/questions/8027685/set-session-cookies-for-specific-subdomains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!