We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10194
    • 16 Posts
    We have multiple installs of MODx and would like it so that when a user logs into the "main" site, he/she can be authenticated on every other site. What would be the best way to make this happen?
      • 6715
      • 4 Posts
      More notes: The sites will all be using Evolution, not revolution. We’d be willing to create the user accounts on the other sites if there is only a way to pass session data between sites. Any ideas or steps towards a solution would be greatly appreciated, so if you have any ideas, start spit-balling here please.
        • 30634
        • 13 Posts
        Hi, I can`t give you direct solution step by step as I have never needed to set up something like that with MODx, but considering php session scheme used by MODx I assume PHP memcache client can get this job done. It’s managing sessions between servers so sharing session between websites sound totally doable smiley.
          http://www.belardesign.com/"" target="_blank" rel="nofollow">Belar Design - web design portfolio, blog with MODx tuts and much more...
          • 6715
          • 4 Posts
          We’d really like to use PHP or something built-in to MODx to do this versus trying to make memcache try to do something it wasn’t built for. There are five different sites on the same server, not the same site on multiple servers. Can anyone explain better how MODx handles logins and sessions? Maybe that will spark an idea on how to share it between MODx installs?
            • 19388
            • 297 Posts
            I really like to hear a solution, it is so interesting. While we wait for a genius I can give you a possible "homemade" solution. If you are using revo you can put all the five sites together but using contexts, in this way you can have www.site1.com , www.site2.com (...) www.siteX.com in the same MODx Revolution installation and share the user accounts and information. This is only theory, because I have not tested it yet, but I think it is possible to do that.
              • 19388
              • 297 Posts
              Idea!
              What if you use AJAX? The problem is that it must be a client side auth and not serverside. But it may work.

              Registration:
              - When a user is registered you propagate that user account throught all the servers ( you must have an "auth api" to do the login/register/change password tasks... ).

              Login:
              - When a user is logged, you send login requests to the other servers using AJAX.

              Logout:
              - Same as Login

              Change password:
              - Same as register
                • 22303 MODX Staff
                • 10,725 Posts
                You cannot just share PHP session data across different domains, only across subdomains (by setting session_cookie_domain to .domain.tld. You would need another mechanism for synchronizing or sharing your data across the domain-targeted sessions.
                  • 30634
                  • 13 Posts
                  Your problem isn`t how MODx use session, it`s different domains and php security terms of cookies where you probably store your session ID. You can try this http://www.gonnalearn.com/2008/04/10/sharing-session-data-across-domains-with-php/
                    http://www.belardesign.com/"" target="_blank" rel="nofollow">Belar Design - web design portfolio, blog with MODx tuts and much more...