We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32046
    • 75 Posts
    I’ve got an "Admin Login" link in my webpage footer, which takes the user to the manager login screen (allowing the client to login to the manager). I would like that link to change to "Admin Logout" if the client is logged in, providing a quick way to logout from the frontend. Providing the correct link text is simple enough with a basic snippet, but how can I actually make the logout happen when the link is clicked? Is there a logout function I can call, or is there a better method?
    Any ideas please?
      • 32046
      • 75 Posts
      bump... thought this would have been pretty simple...
        • 38162
        • 97 Posts
        I can think of a few possible ways to do that. For instance:

        - unset the manager SESSION variables, e.g. unset($_SESSION[’webUser’]); etc. (a bit tedious)
        - destroy and restart the session: session_destroy(); startCMSSession(); (logs out web user as well though)
        - use the url that is used within the manager as well ./manager/index.php?a=8 . In that case you would have to handle the referer though (didn’t try that yet).

        In all cases you would need to send the user to a php script, which then sends the user back to a page (e.g. home), once logged out.
          • 3749
          • 24,544 Posts
          This will work as a logout link if you have weblogin (might work with login as well):

          <a href="[~12~]?webloginmode=lo">Logout</a>


          Replace 12 with the ID of your login page.
            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