Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leviwheatcroft/70d72c2f2b3ae4e0ea4b to your computer and use it in GitHub Desktop.
Save leviwheatcroft/70d72c2f2b3ae4e0ea4b to your computer and use it in GitHub Desktop.
Single Sign On for modx external authentication super handy if you're authenticating with some other project and just need to assign privileges to a session.
<?php
//require 'modx/assets/kint/Kint.class.php';
require_once __DIR__ . '/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 = $modx->getObject('modUser', array('username' => 'levi'));
$user->addSessionContext('mgr');
//dd($user->get('username'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment