After a server update (My server has Centos 6.5 final ) the login stopped working.
I used the default authentication method and after a successful login I’m redirecting the user to the backend module.
This was working perfectly.
public function actionLoginForm(){
if(Yii::app()->user->isGuest)
{
$model=new LoginForm;
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the backend page if valid
if($model->validate() && $model->login())
{
Yii::log("User ".Yii::app()->user->name." logged in.", CLogger::LEVEL_INFO, "FrontSite.login");
$this->redirect(Yii::app()->baseUrl."/index.php/UserBackend/Panel/home");
}
else{
$this->redirect(Yii::app()->baseUrl."/index.php/frontSite/login");
}
}
// display the login form
$this->renderPartial('login-form',array('model'=>$model));
}
else
{
$this->renderPartial('login-form');
}
}
When the credentials are correct, the user before the redirect is logged in. I know this cause if I check with “Yii::app()->user->isGuest” I’m getting false.
But after the redirect, in the Panel/home action, the same isGuest function returns TRUE and because user is not logged in, the system redirects him back to index page with a "302 Moved Temporarily" message on the chrome console for the loginForm action.
Why is the session disappear after redirect?
And why this is happening after the system update.
PHP version is 5.3.3.