m使用下面提到的代码,但是如果条件第二个块的第二个失败, 每次页面被重定向到第二个if块中提到的链接。
if($_session['redirect']=='')
{
Yii::app()->session['redirect'] = 'redirect';
}
if(Yii::app()->session['redirect']=='redirect')
{
Yii::app()->session['redirect'] = 'redirect_test';
$this->redirect(array('/site/page','view'=>"nh7"));
}
答案 0 :(得分:0)
请尝试这个:
if(!Yii::app()->user->hasState('redirect'))
Yii::app()->user->setState('redirect', 'redirect');
if(Yii::app()->user->hasState('redirect')) {
$redirect = Yii::app()->user->getState('redirect');
if($redirect == 'redirect') {
Yii::app()->user->setState('redirect', 'redirect_test');
$this->redirect(array('/site/page','view'=>"nh7"));
}
}
请使用Yii:app()->user->setState()
,setState()
和getState()
而不是Yii::app()->session['key']