多个域之间的会话保持?

发布于 2024-10-06 18:23:18 字数 104 浏览 0 评论 0原文

有什么方法可以在同一服务器上为多个域建立公共会话,对于我们使用session_cookie的子域,这样我就可以为子域建立公共会话。

请帮忙!!!

Is there any way to make common session for multiple domains on the same server, for sub domains we are using session_cookie so i am able to make common session for sub domains.

please help!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

素染倾城色 2024-10-13 18:23:18

您应该将会话数据存储在数据库中,这是通过将保存处理程序“重新路由”到数据库保存函数来完成的,如下所示:

session_set_save_handler ( callback $open , callback $close , callback $read , 
                           callback $write , callback $destroy , callback $gc )

回调是显而易见的。如果你在谷歌中快速搜索,你会发现很多关于这个问题的教程,所以你不必从头开始编写它。另外,如果您要实现自己的会话类,请务必阅读 Chriss Shiflett 的文章“关于会话的真相

You should store you session data in the database, this is accomplished by "rerouting" the save handler to your DB saving functions, like this:

session_set_save_handler ( callback $open , callback $close , callback $read , 
                           callback $write , callback $destroy , callback $gc )

The callbacks are obvious. if you make a quick search in Google you'll find a bunch of tutorials on the matter, so you won't have to write it from scratch. Also, if you are going to implement your own session class, be sure to read Chriss Shiflett's article "The Truth about sessions"

绮筵 2024-10-13 18:23:18

以下链接可能对您有帮助。

如何维护 PHP 会话跨同一服务器上的多个域?

http://www.daniweb.com/ forums/thread180252.html

重要的是,您应该有一个用于会话存储的公共位置,正如大卫建议的那样,所有域(例如数据库)都可以访问该存储位置

Below links may help you.

How do I maintain PHP sessions across multiple domains on the same server?

http://www.daniweb.com/forums/thread180252.html

The important thing is that you should have common place for session storage which will be accessed by all domains like database as suggested by david

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文