在具有不同域的多台服务器之间共享SESSION [英] Share a SESSION across multiple servers with different domains

查看:199
本文介绍了在具有不同域的多台服务器之间共享SESSION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题.我正在用PHP开发一个分为模块的应用程序.每个模块都是完全独立的,位于单独的服务器上,并具有自己的域.例如:

I'm having a little problem. I am developing an application in PHP that is divided into modules. Each module is completely independent, is on a separate server and has an own domain. eg:

www.moduloprincipal.com.br,www.modulo2.com.br,www.modulo3.com.br等...

www.moduloprincipal.com.br, www.modulo2.com.br, www.modulo3.com.br, etc ...

问题是,我需要用户在对其中一个模块进行身份验证时,可以在无需再次进行身份验证的情况下访问同一用户的其他模块.

The problem is that I need that when a user to authenticate to one of the modules (either) the user can access the same user other modules without having to authenticate again.

当前,每个应用程序都位于不同的服务器上,但是如果有必要,它们都位于同一服务器上,这将不是问题.

Currently each application is on a different server, but if necessary they are in the same server, it would not be a problem.

重要提示:

  1. 读取了多个线程,但是没有找到真正安全的解决方案.使用OAuth会很有趣吗?

  1. Read several threads, but found no solution really safe. Will be interesting to use OAuth?

当前,应用程序使用$ _SESSION来验证用户身份,但是您可以顺利使用$ _COOKIE.

Currently the application uses $ _SESSION to authenticate users, but you can use $ _COOKIE smoothly.

我正在使用CodeIgniter

I'm using CodeIgniter

由Google翻译翻译.抱歉...

Translated by Google Translate. Sorry ...

推荐答案

从我的头上可以探索的两个选项:

Two options from the top of my head that you can explore:

  • 设置所有服务器相​​同的路径以保存其会话数据,请参见 session.save_path 指令.该位置可能是NFS共享 或您所有服务器都可以访问的NAS位置.

  • Set all servers the same path for saving its session data, see session.save_path directive. That location could be a NFS share or a NAS location that all your servers could access.

另一个选项是实现数据库会话处理程序,因此 会话数据可以在所有人之间共享 您的服务器访问同一数据库服务器.因此,请看一下PHP文档 用于自定义会话处理程序.

The other option is to implement a database session handler, so the session data could be shared among all your servers accessing the same database server. So take a look at PHP docs for custom session handlers.

这篇关于在具有不同域的多台服务器之间共享SESSION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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