跨2个顶级域的PHP cookie [英] PHP cookie across 2 top level domains

查看:276
本文介绍了跨2个顶级域的PHP cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个网域(例如test1.com和test2.com),我需要这两个网域的使用者登入。

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

推荐答案

您无法使用Cookie,因为Cookie只能显示在同一网域。

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

一个解决方案是将用户重定向两次,一次到其他网站,包括网址上的一些身份验证信息,让该网站将其设置为登录Cookie,然后第二次重定向回到登录页面第一个网站。

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.

执行两个重定向的原因是,许多浏览器不接受3:rd方Cookie,通过图像或javascript链接设置cookie可能不工作。

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.

这篇关于跨2个顶级域的PHP cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆