Hi Everyone.
I am stuck here and have no clue what is going wrong. I am using Revo 2.2.1 and using the snippet Login to authenticate my users to the front-end.
I did setup the Login according to basic.setup tutorial. The login it self works. I did set two resources and the user sees them depending in which group he is assigned. so far so good.
I use many jquery ajax calls to load data. So basically I want to make an authentication query to check if the user is logged in...
So the login snippet says that the user is logged in and also displays the name and the correct resources. but the ajax call can't seem to access the same session...
when i print_r($_SESSION) i get this:
Array
(
[modx.user.contextTokens] => Array
(
)
[modx.web.user.token] => 0
)
so it's empty. I did setup a connecter that I include first in all my PHP files that are called with ajax...
here the code:
// Adds DB Functionality to the ajax frontend. Also Session management
define('MODX_BASE_PATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/');
define('MODX_CORE_PATH', MODX_BASE_PATH . 'core/');
define('MODX_MANAGER_PATH', MODX_BASE_PATH . 'manager/');
define('MODX_CONNECTORS_PATH', MODX_BASE_PATH . 'connectors/');
define('MODX_ASSETS_PATH', MODX_BASE_PATH . 'assets/');
define('MODX_CONFIG_KEY', 'config');
if(is_dir(MODX_CORE_PATH)) {
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('web');
// ADD PACKAGE
$base_path = !empty($base_path) ? $base_path : $modx->getOption('core_path').'components/projectx/';
$modx->addPackage('projectx',$base_path.'model/');
} else {
echo "Finde Pfad: ".MODX_CORE_PATH." in projectx/lib/xpdo.php nicht. wrong path";
die();
}
I am not so sure here if I should inizialize "web" or "mgr" but I think web is fine, because I don't want to change anything in the manager nor on resources...
To check if the user is authenticated I use:
if (!$modx->checkSession('web')) { $modx->sendUnauthorizedPage(); }
but even when I am logged in, modx sends the user to the unauthorized page...
how can I make the Login function registering the user in a way that I can access all data with the $modx objects?
Thank you for any suggestions that could help me solve my issuee