开发者

sharing cookies across domains on same host

I'm trying to maintain a web site spread across two domains with the same host (one is actually in a subfolder of the other):

www.a.com  -> /.../public_html/
www.b.com  -> /.../public_html/b/

I have one script on a.com, let's call it public_html/readcookiedata.php, which reads in some session variables from a cookie. Another script on b.com, let's say public_html/b/index.php, need开发者_运维技巧s to also read this cookie.

Right now index.php tries to require_once(../readcookiedata.php).

This works great if I visit www.a.com/b/index.php: the cookie is read OK. However, if I browse to there directly, www.b.com/index.php, the cookie isn't read.

What's the best way to fix this problem? Is there a way for a.com to allow b.com to read its cookies? Or some way to configure the host to treat all requests to b.com as if they were for a.com/b/ instead?


No. Cookie security is built into the web at a browser level; browsers literally won't allow you to read data for cookies from other domains on pages served by a different domain.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜