PHP Cookies for multiple Domains(多个域的 PHP Cookie)
问题描述
一旦用户在 PHP 中注册,我想从一个域创建一个 cookie.并使这个 cookie 可以被其他 4 个域而不是子域访问.我知道 cookie 并非设计为可供其他域访问.例如,我从域 www.firstdomain.com 设置了一个 cookie 变量 $user_email 并希望在其他域中访问它,例如 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:多个域的 PHP Cookie
基础教程推荐
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
