#### 问题描述
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());
$this->printf('<p>'. $lang->getShouldHaveBeenRedirected(). '</p>', $cas_url);
$this->printHTMLFooter();
phpCAS::traceExit();
throw new CAS_GracefullTerminationException();
}
#### 为此你搜索到了哪些方案及不适用的原因
项目需要实现单点登录,用的是apereo/phpcas这个包,但是执行到跳转到cas服务器的时候,header执行不了,也就是上面这个
if (php_sapi_name() === 'cli') {
@header('Location: '.$cas_url);
} else {
header('Location: '.$cas_url);
}
位置,其中webman是cli模式。
有好的解决方案么?
搜了下,header在cli模式下不可用。