开发者

PHP cookie across 2 top level domains

开发者 https://www.devze.com 2023-01-22 00:58 出处:网络
I have 2 domains (e.g. test1开发者_如何学运维.com and test2.com) and I need a user login across these 2 domains.

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. :)


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号