PHP读取在另一个域上的cookie [英] PHP read a cookie that is on another domain
问题描述
我有两个网域。一个域包含登录脚本。
I have two domains. One domain contains the login script. It creates a cookie when logged in. Another domain have a URL shortener.
因此,在具有URL Shortener脚本的第二个域上有一个名为session.php的文件。通常我使用 $ _ COOKIE ['sessionid']
获取会话ID,并使用数据库匹配它。
So, on the 2nd domain that have the URL Shortener script have a file called session.php. Usually I was using $_COOKIE['sessionid']
to get the session id and match it using database.
如何获取会话ID?我尝试了几种方法,但没有一个解决我的问题。
How can I get the session id now? I have tried few ways but none of them have solve my problem.
推荐答案
出于安全原因,属于另一个域的Cookie。
For obvious security reasons, you can't read a cookie that belongs to another domain. You can do it across sub-domains though.
为什么不将会话ID附加到转发的网址?
Why not append the session id to the forwarded URL?
这篇关于PHP读取在另一个域上的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!