Share a SESSION across multiple servers with different domains

11,725

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

  • 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.

  • 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.

Share:
11,725
Admin
Author by

Admin

Updated on July 19, 2022

Comments

  • Admin
    Admin almost 2 years

    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, 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.

    IMPORTANT:

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

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

    3. I'm using CodeIgniter

    Translated by Google Translate. Sorry ...

  • Get Off My Lawn
    Get Off My Lawn about 11 years
    He could also have one server act as an API that handles all the session information.