} else {
if (isset($_GET['slo'])) {
$returnTo = null;
$paramters = array();
$nameId = null;
$sessionIndex = null;
if (isset($_SESSION['samlNameId'])) {
$nameId = $_SESSION['samlNameId'];
}
if (isset($_SESSION['samlSessionIndex'])) {
$sessionIndex = $_SESSION['samlSessionIndex'];
}
$auth->logout($returnTo, $paramters, $nameId, $sessionIndex);
} else {
if (isset($_GET['acs'])) {
$auth->processResponse();
return;
$errors = $auth->getErrors();
if (!empty($errors)) {
print_r('<p>1' . implode(', ', $errors) . '</p>');
}
if (!$auth->isAuthenticated()) {
echo "<p>2 Not authenticated</p>";
exit;
}
$_SESSION['samlUserdata'] = $auth->getAttributes();
$_SESSION['samlNameId'] = $auth->getNameId();
$_SESSION['samlSessionIndex'] = $auth->getSessionIndex();
if (isset($_POST['RelayState']) && OneLogin_Saml2_Utils::getSelfURL() != $_POST['RelayState']) {
$auth->redirectTo($_POST['RelayState']);
}