We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21120
    • 30 Posts
    I have a multi-subdomain setup, and i’m fairly certain that i have all the access controls set up properly.

    it’s only allowing me to log in and out of each context separately. I looked through the login snippet code, and it appears that’s how the snippet is supposed to work.

    Is there a way to have the login snippet synchronize logins across all contexts that the user has access to?
      • 22295
      • 153 Posts
      You could login on behalf of the user via the processor

       // use the credentials you got
       $_POST['username'] = $username;
       $_POST['password'] = $password;
      
       // in another context
       $_POST['login_context'] = 'contextNameHere';
       
       /* send to login processor and handle response */
       $response = $modx->executeProcessor(array(
         'action' => 'login',
         'location' => 'security'
       ));
       if (!empty($response) && is_array($response)) {
         if (!empty($response['success']) && isset($response['object'])) {
      // logged in successfully
        }
       }
      



      That’ll work - but, I am sure there’s a cleaner way than that...

        • 22303 MODX Staff
        • 10,725 Posts
        The issue is that the Login snippet needs to be updated to allow login to multiple contexts at once.