多个域的PHP Cookie [英] PHP Cookies for multiple Domains

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

问题描述

一旦用户在PHP中注册,我想从一个域创建一个cookie。并使此Cookie可以访问其他4个域而不是子域。我知道cookie不是为其他域访问的。例如,我设置了一个cookie变量$ user_email从域www.firstdomain.com,并希望访问它在其他域如www.seconddomain.com,www.thirddomain.com等。可能是这可以使用PHP或JavaScript。任何想法。

I want to create a cookie from one domain once the user is registered in PHP. and make this cookie accessible to 4 other domains not subdomain. I know that cookies are not designed to be accessible for other domains. For example I have set a cookies variable $user_email from domain www.firstdomain.com and want to access it in other domains like www.seconddomain.com, www.thirddomain.com etc. May be this can be done using PHP or JavaScript. Any idea please.

谢谢!

推荐答案

已经说过,只能为来自该域(包括其子域)的域设置Cookie。如果您的网域不共享同一个超级域,您需要分别为每个网域分别设置每个Cookie。

As you have already said, a cookie can only be set for a domain from that domain (including its subdomains). And if your domains do not share a common superdomain, you need set each cookie for each domain separately.

您可以使用脚本来设置每个网域, cookie为你。但请务必验证对这些脚本的请求,以便只能设置Cookie。

You can do this with a script that on each domain that sets the cookie for you. But make sure to authenticate requests to these scripts so that only you can set the cookies.

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

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