We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 54543
    • 1 Posts
    I try to do login via AJAX:

    $output = $modx->runProcessor('security/login', array(
    'username' => trim($_POST['username']),
    'password' => trim($_POST['password']),
    ));
    if ($output->response['success']){ //login ok
    echo $modx->user->id; // always print 0, but if refresh page login is successful

    Anybody can help me? thanks so much
      • 46886
      • 1,154 Posts
      Here is a thread where they discuss this. User whitebyte has this advice:

      To run the processor, you should perform

      $response = $modx->runProcessor('action/path/to/processor',$arrayOfProperties,$otherOptions);


      https://forums.modx.com/thread/95621/is-there-a-such-thing-as-login-logout-api

      So your code matches up but is it all in one line? I am pretty sure for php it needs to be in one line with no unnecessary returns

      You've also got a double right paranthasis when you should have one, here:

      ));