API Quick reference
Variable name: getLoginUserID
CMS versions: 0.9.x + Evo
Input parameters:
Return if successful: Logged in user ID
Return type: int
Return on failure:
Object parent:


Description / Usage

integer getLoginUserID( );

Determines if user is logged in, be it via the admin Interface, or Web Interface, and returns the ID (int) of the current user. If no user is logged in, null is returned.

  • $context can be either 'web' or 'mgr'. Returns nothing if the user is not logged in.

Returns current user id.


// In the front end, returns an array of the logged in user's attributes.
$userInfo = $modx->db->getRow(


In the Admin Interface, the value returned will be the Admin Interface user's ID.

Function Source

File: manager/includes/
Line: 2015

function getLoginUserID($context= '') {
if ($context && isset ($_SESSION[$context . 'Validated'])) {
return $_SESSION[$context . 'InternalKey'];
elseif ($this->isFrontend() && isset ($_SESSION['webValidated'])) {
return $_SESSION['webInternalKey'];
elseif ($this->isBackend() && isset ($_SESSION['mgrValidated'])) {
return $_SESSION['mgrInternalKey'];

Suggest an edit to this page.