[英]Unable to logout of Yii app & force page to redirect (Yii 1.x)
我試圖讓我的Yii應用程序在特定類型的用戶登錄后經過設置的秒數后自動注銷。
我對我的protected / components / WebUser.php文件做了以下修改:
public function init() {
parent::init();
if (($user = $this->getState('userModel')) !== null) {
$this->setUserData(unserialize($user));
if ($this->isNonAdminUser()) {
$this->authTimeout = 3600; // 1 hour timeout
}
}
$this->updateAuthStatus();
}
// function automatically directly after $this->logout()
protected function afterLogout() {
Yii::app()->request->redirect(('site/front/login'));
//Yii::app()->request->redirect((Yii::app()->user->returnUrl));
}
在沒有活動1小時后,這基本上會從會話中注銷“非管理員用戶”-這可行,但是我也希望能夠將其“強制”返回首頁。 我試圖在afterLogout()中使用重定向功能,但是由於某種原因它似乎沒有進行重定向?
任何想法為什么不呢?
注意-我正在使用Yii 1.x
嘗試在afterLogout
函數中使用Yii::app()->user->homeUrl
而不是Yii::app()->user->returnUrl
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.