最近有一个项目里,前后台分离(用户pannel与front-end分离;并与管理平台分离);前端用户与后台管理员用户同时登陆,发现注销时会同时退出;故更改了CWebUser.php里的logout方法
public function logout($destroySession=true)
{
if($this->beforeLogout())
{
if($this->allowAutoLogin)
{
Yii::app()->getRequest()->getCookies()->remove($this->getStateKeyPrefix());
if($this->identityCookie!==null)
{
$cookie=$this->createIdentityCookie($this->getStateKeyPrefix());
$cookie->value=null;
$cookie->expire=0;
Yii::app()->getRequest()->getCookies()->add($cookie->name,$cookie);
}
}
if($destroySession)
Yii::app()->getSession()->destroySession(Yii::app()->getSession()->sessionID);
else
$this->clearStates();
$this->afterLogout();
}
}
更改过的地方是这一句
Yii::app()->getSession()->destroySession(Yii::app()->getSession()->sessionID);
虽然,我知道改动框架核心并不是稳妥的方法,但目前还想不到其它的好方法,不知各位大侠是如何解决这个问题的。
另:因结构布局的问题会员的logout方法已继承了CAction