Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save eshleebien/ffbab4bee8a6a9c103d2 to your computer and use it in GitHub Desktop.

Select an option

Save eshleebien/ffbab4bee8a6a9c103d2 to your computer and use it in GitHub Desktop.
Log in a user programmatically in MODx, answer (hopefully) to a question posted in the forums here; http://forums.modx.com/thread/86714/is-it-possible-to-login-a-user-programmatically-in-frontend
<?php
$id = 1; // just an example ... use appropriate id
$user = $this -> modx -> getObject('modUser', $id);
if (!$user -> hasSessionContext('web')) {
$user -> addSessionContext('web');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment