$response = $modx->runProcessor('action/path/to/processor',$arrayOfProperties,$otherOptions);
`
In short, processors are some kind of utility classes used by modx core and manager. They are located in /core/model/modx/processors. For example, logout processor located in security/logout subfolder, it's name is logout.php. Look at the code, it's pretty self-explanatory.
$user->addSessionContext($contextName);
$response = $modx->runProcessor('security/logout');
IIRC, you can also forward the user to the login page with ?service=logout on the end of the URL.
Logging a user in is fairly simple:
$user->addSessionContext($contextName);
<?php if ( $modx->user->get('id') != '' && $modx->user->get('username') != '(anonymous)') { $_SESSION['isLoggedIn'] = true; $_SESSION['userName'] = $modx->user->get('username'); $_SESSION['uid'] = $modx->user->get('id'); $_SESSION['moxiemanager.filesystem.rootpath'] = "/".$modx->user->get('username'); } else { unset( $_SESSION['isLoggedIn'] ); unset( $_SESSION['userName'] ); unset( $_SESSION['uid'] ); unset( $_SESSION['moxiemanager.filesystem.rootpath'] ); } // Comment out everything below this line for production envronments. print_r($_SESSION);
if ($modx->user->hasSessionContext('web')) { /* User is logged in to web context */ } else { /* User is NOT logged in to web context */ }