We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21524
    • 90 Posts
    Hi everyone,
    I have 2 websites that have 100% similar users. So, what I want to do is share one user database between 2 websites.
    And if registered on one, a person could log in to the second one without any need for a new registration. And vice versa.

    I know that theoretically it is possible.
    But is it possible practically?

    Also, is it possible to share Cookies too? (I’m not strong with that). So, a user could be remembered on both of the sites.

    Thanks
      • 26903
      • 1,336 Posts
      Are the websites on the same host? or more specifically are they running under the same MYSQL server?
        Use MODx, or the cat gets it!
        • 21524
        • 90 Posts
        yes, they are.
        they just have two separate modx installations. but they are running on the same host and mysql server.
          • 26903
          • 1,336 Posts
          I think you would have to make one of the tables the master and one the slave, the master holds the real copy of the data, the slave just references it either through its own database(federated) or directly.

          The problem with directly is that you’ll have to open a connection to the master database from the slave when this table is accessed, bypassing its own table, this of course means hacking the core to do this.

          If you are running MYSQL5 you can do this using federated tables, see this link http://dev.mysql.com/doc/refman/5.0/en/federated-use.html.
          You would still need the master/slave thing, but you can do this without touching the core, the slave would just operate on its own table, not knowing it is really referencing the master. You would also need to drop the web_user_attributes table in the slave database when you create your federated table so be careful of data loss.

          If you can use the federated method another way to do this would be to abstract common data into a third database, visible to all your installations and let this be the master for all of them with suitable federated tables in all your slaves.

          So yes, theoretically its possible but depending on your set-up may or may not be practical.
            Use MODx, or the cat gets it!
            • 10449
            • 956 Posts
            Are we talking about the same TLD? One is e.g. shop.domain.com and the other www.domain.com?
            Or two completely separate domains? www.domain1.com + www.domain2.com?

            Sharing cookies across TLDs is painful at best. Most browser’s default settings don’t accept them. You can "mirror" cookies across domains with some kind of redirect trickery, but it’s not trivial.

            If we’re just talking about a different subdomain, then you just have to make sure cookies are set with a * (wildcard).

            But in any case, web-users in MODx are controlled via sessions, not cookies...
              • 21524
              • 90 Posts
              thanks for your answers. Especially the Federated thing would be helpful i guess.

              Thanks a lot.