public function redirectToCas($gateway = false, $renew = false)
{
phpCAS::traceBegin();
$cas_url = $this->getServerLoginURL($gateway, $renew);
session_write_close();
if (php_sapi_name() === 'cli') {
@header('Location: ' . $cas_url);
} else {
header('Location: ' . $cas_url);
}
phpCAS::trace("Redirect to : " . $cas_url);
$lang = $this->getLangObj();
$this->printHTMLHeader($lang->getAuthenticationWanted());
printf('<p>' . $lang->getShouldHaveBeenRedirected() . '</p>', $cas_url);
$this->printHTMLFooter();
phpCAS::traceExit();
throw new CAS_GracefullTerminationException();
}