Vanilla Forums – Authenticate outside of the forum
Check if a user is logged into a vanilla forum on the current website, from an external script (if that makes sense)
Testing with my vanilla forum (click FORUM above):
IsValid()) {
$Name = $Session->User->Name;
echo “You are logged in as $Name“;
}else{
echo “You are not logged in“;
}
?>
define('APPLICATION', 'Vanilla');
define('APPLICATION_VERSION', '2.0.16');
define('DS', '/');
define('PATH_ROOT', dirname(__FILE__));
ob_start();
require_once(PATH_ROOT.DS.'bootstrap.php');
ob_end_clean(); // clear any header output from vanila
$Session = Gdn::Session();
$Authenticator = Gdn::Authenticator();
if ($Session->IsValid()) {
$Name = $Session->User->Name;
echo "You are logged in as $Name";
}else{
echo "You are not logged in";
}