I'm trying to log a front end user into modx via and external script containing the login processor.
I've got no issues with the runProcessor as the file logs in fine if I view the file directly within a browser, but there seems to be an issue when the file is loaded via curl.
This file is used from magento using curl and it seems to login the user in, in terms of returning a successful response. I'm getting
["success"]=>
bool(true)
["message"]=>
string(0) ""
["total"]=>
int(0)
["errors"]=>
array(0) {
}
["object"]=>
array(2) {
["url"]=>
string(0) ""
["token"]=>
string(52) "modx57516511372036.00159532_257683f2492d6d2.48933569"
}```
And even within the manager the users login count goes up.
But if I viewing protect pages it's as if your not logged in. It doesn't look like the correct session ID is getting set within the modx_session table.
This is the code that i'm using to login within an external file.
<?php
require_once '/home/site/public_html/modx/config.core.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError', '', '');
$user = $_REQUEST;
if ($user && isset($user['username'])) {
$loginContext = $modx->context->get('key');
$c = array(
'login_context' => $loginContext,
'username' => $user['username'],
'password' => $user['password'],
'returnUrl' => null,
'rememberme' => false
);
$response = $modx->runProcessor('security/login', $c);
return true;
}
Any ideas?