I don’t believe how easy this is! Complete user integration, single-sign on.
1. Requires Vanilla 2 (at this point 2.0.3 is the latest). This must be on the same domain as your MODx site, since Vanilla has to be able to see the MODx cookie. (you can determine if this will work by putting a line in the main Vanilla index.php file
this must show the cookie for MODx; you can check the cookie name against the $site_sessionname in the MODx config.inc.php file)
2. Install the
SSO ProxyConnect plugin, enable it, activate the ProxyConnect method and fill out the configuration fields (which consist of the URLs to the various MODx pages you want to use and the cookie domain, which probably will be OK with the default). Log out of Vanilla.
3. Create a snippet with the following code:
<?php
if(isset($_SESSION['webInternalKey'])) {
$output = "UniqueID=" . $_SESSION['webInternalKey'] . "\n\n";
$output .= "Name=" . $_SESSION['webShortname'] . "\n\n";
$output .= "Email=" . $_SESSION['webEmail'] . "\n\n";
return $output;
}
return;
?>
4. Create a resource with no template, in fact nothing set except published, and the above snippet tags as its content. Basically, what you need is a page that does absolutely nothing but output those three values.
5. Create a plugin using the OnWebLogout system event with the following code:
$e = &$modx->Event;
switch($e->name) {
case 'OnWebLogout': // integrated logout
setcookie('Vanilla', ' ', time() - 3600, '/', '.domain.com');
unset($_COOKIE['Vanilla']);
break;
}
Now you log in to MODx, and when you go to Vanilla you’ll get a popup asking if you want to create a new Vanilla account or sync with an existing Vanilla account (mostly useful for syncing to the existing admin account). Once that’s done, the user is now established. Log in, log out and register in MODx, and you’re automatically logged in to Vanilla when you’re logged in to MODx.