We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22980
    • 84 Posts
    I have a page on my site, and would like admins to be able to edit it right from that page. Although this is questionable best practice, it is effective. I’ve been trying to use userLoggedIn() without any luck - assumedly that only works when one is inside the manager.

    Help? Thanks!
    --Peter
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      What version of MODx are you using?
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22980
        • 84 Posts
        (whoops, forgot to set this topic to notify)

        The latest one - MODx Revolution 2.0.0-pl rev7212

        Thoughts? *appreciate*
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I don’t know for Revo, sorry.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 22980
            • 84 Posts
            hmm. Any juicy details on sessions and logins would be handled - how one would load up session stuff if not in /manager? Any quick info on how it was done in evo?

              • 28042 ☆ A M B ☆
              • 24,524 Posts
              In Evo, if you’re a logged-in Manager user there is a whole buch of stuff in the SESSION; usually the $_SESSION[’mgrValidated’] field is checked (should be 1 if it’s a logged-in manager user).

              Easy to find out; make a simple snippet
              <?php
              echo "<pre>";
              print_r($_SESSION);
              echo "</pre>";
              

              put it on a "test" resource, and check it out with various logins.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 22980
                • 84 Posts
                bingo! You rock!

                $_SESSION[’mgrValidated’] => 1
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I wrote an article on sessions in Evo, with a login form on the page for web login, and of course one can log in to my Manager as the guest user. It has the snippet to display the SESSION. I actually put it there more for my own use, as frequently I need to do something based on some SESSION value or another, and this way I have it handy!
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 3749
                    • 24,544 Posts
                    Here’s the scoop on logged-innedness in Revo:

                    In the common case where you only have the ’web’ context:
                    $isAuthenticated = $modx->user->hasSessionContext('web');

                    If you are using multiple contexts and want to know if the user is logged in to the current context, you can do this:
                    $isAuthenticated = $modx->user->hasSessionContext($modx->context->get('key'));

                    If you are using multiple contexts and want to know if the user is logged in to any of them, this code will do it:
                    $isAuthenticated = $modx->user->hasSessionContext(array('context1', 'context2', 'context3'));

                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 22980
                      • 84 Posts
                      Thanks!

                      Is there something wrong with the ’$_SESSION[’mgrValidated’] => 1’ method?

                      I tried looking for source online - but no luck (http://rtfm.modx.com//display/revolution20/modUser.hasSessionContext). Is method source online anywhere?