PHP cookie across 2 top level domains

风流意气都作罢 提交于 2019-12-12 05:00:07

问题


I have 2 domains (e.g. test1.com and test2.com) and I need a user login across these 2 domains.

Both domains run on the same server. I hope for some help. :)


回答1:


As there is no way to set something like "global cookies", you have to solve this on the server side somehow.




回答2:


You cannot use a cookie as cookies are only visible on same domain.

One solution is to redirect the user twice, once to the other site including some authentication info on the url to have that site set its on logged in cookie, and a second redirect back to the logged in page on the first site.

The reason to do two redirects is that many browsers do not accept 3:rd party cookies and setting the cookie through an image or javascript link might not work.



来源:https://stackoverflow.com/questions/4013204/php-cookie-across-2-top-level-domains

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