-
- 98 Posts
Hi,
I'm trying to give access to some contexts based on whether the visitor is logged into the manager. Using my custom context switcher plugin.
I have tried $modx->user->get('username') but that returns (anonymous) even when the user is logged into the manager.
$modx->user->hasSessionContext($modx->context->get('mgr')) doesn't return anything.
$_SESSION['mgrValidated'] doesn't return anything.
I'm using MODX 2.1.2.
That would be
$modx->user->hasSessionContext('mgr');
-
- 98 Posts
Also I should say, it's a plugin executing OnHandleRequest. If that matters.
-
- 24,544 Posts
If you want to check for logged-in status in the current context, you want:
if ($modx->user->hasSessionContext($modx->context->get('key'))) {
/* user is logged in */
}