We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    I'm using 2.1.3. If I am logged into the web context as a user other than anonymous (but not yet logged into manager), and then in another browser tab log in to manager, I would like my web session to be logged in as the manager user also. It seems like this used to be the default behavior (but maybe I'm remembering that wrong).

    Among other things, you are unable to preview/view unpublished resources from manager in this scenario, unless/until you manually log the non-mgr web user out.

    Is there a way to ensure that if I'm logged in to manager, I'll be the manager user in the web context as well?
      • 22303 MODX Staff
      • 10,725 Posts
      Not if you are logged into the other Context as well. As long as you are in the same browser session, you will have the session data for both users which you are logged in as, but the data will be isolated per Context (i.e. your admin user logged into 'mgr' and web user logged into 'web').

      The only time being logged into the mgr Context will provide the mgr user's permissions in other Contexts is if you are not logged in specifically to those other Context( s ).
        • 14883 ☆ A M B ☆
        • 450 Posts
        Would there be any way to use an OnManagerLogin plugin to log out the 'web' context's session and log it back in as the manger user? Or is the separation so complete that there is no reliable way of verifying which session is the right one (the other one I'm logged in to in the same browser)? Would I have to resort to matching IP address, browser identifier, etc.?

          • 22303 MODX Staff
          • 10,725 Posts
          Sure:

          <?php
          if ($user instanceof modUser) {
              $user->removeSessionContext('web');
          }
            • 14883 ☆ A M B ☆
            • 450 Posts
            That worked, but only after I added "$user->addSessionContext('web'); after the removeSessionContext.

            But this causes a side effect: once I log *out* of Manager, I'm still logged in to the web context as the manager user, which isn't good. Simple enough to fix though, with an "onManagerLogout" event that again removes the web session.

            Thanks for your help!