Reputation: 6645
This problem isset only in Chrome and Firefox. Opera and Safari works fine. On login, I don't checking rememberMe option.
allowAutoLogin set to TRUE
Here is my login method from LoginForm model:
public function login()
{
if ($this->_identity === NULL)
{
$this->_identity = new UserIdentity($this->login, $this->password);
$this->_identity->authenticate();
}
if ($this->_identity->errorCode === UserIdentity::ERROR_NONE)
{
$duration = $this->rememberMe ? 3600 * 24 * 30 : 0; // 30 days
Yii::app()->user->login($this->_identity, $duration);
return TRUE;
}
else
return FALSE;
}
And here is my action:
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()) $this->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->render('login', array('model' => $model));
}
Upvotes: 3
Views: 3264
Reputation: 5913
In the config (protected/config/main.php) you can change allowAutoLogin to false
'components' => array(
'user' => array(
// enable cookie-based authentication
'allowAutoLogin' => false,
),
Read more about Yii login states here http://www.yiiframework.com/doc/api/1.1/CWebUser
Upvotes: 1