We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38199
    • 2 Posts
    Could someone give me some examples of how to manage a login/logout for a "web" user via the API? Have figured out that I need to something the the following:

    Login: $modx->runProcessor('security/login', array());

    Logout: $modx->runProcessor('security/logout', array());

    /J
      • 3749
      • 24,544 Posts

      This should do it:

      <?php
      $_POST['username'] = $user;
      $_POST['password'] = $pass; 
      $_POST['service'] = 'login';
      $_REQUEST['service'] = 'login';
      $scriptProperties['loginResourceId'] = 499; // page you want to forward them to, if any
      
      $modx->runSnippet('Login', $scriptProperties);
      


      For logout, I think you can just change login to logout and leave out the username and password.
        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
        • 38199
        • 2 Posts
        Thanks! Will try!