I’m hoping someone can point me in the right direction. What I’m doing is setting a session variable upon login during the actionLogin like so:
public function actionLogin()
{
$model=new LoginForm;
// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login()){
Yii::app()->session['userRole'] = Yii::app()->user->type;
$this->redirect(Yii::app()->user->returnUrl);
}
}
// display the login form
$this->render('login',array('model'=>$model));
}
So in one of my layouts I have the following code:
The first time that layout is used I’m able to use the $userRole session information. But the NEXT and any SUBSEQUENT times the session data is gone. Anyone have any idea where I’m going wrong?