Hi,
I have the "remember me" functionality implemented on my web application but is not working as i think it was suppose to.
What happens is the following:
-
I login using "rememberMe" and i set a bunch of state variables with Yii::app()->user->setState method
-
When i comeback next day, the user is not a Guest (Yii::app()->user->isGuest returns false) but the state variables that i set for the user on login are not there (so obviously the app crashes).
What am i doing wrong here?
More info:
I am using database session:
'session' => array(
'class' => 'system.web.CDbHttpSession',
'connectionID' => 'db',
'timeout' => 14400,
'autoCreateSessionTable' => false
),
I have allowed auto login:
'user' => array(
'loginUrl' => array('site/index'),
// enable cookie-based authentication
'allowAutoLogin' => true,
'autoUpdateFlash' => false
),
My login function is the following:
public function login() {
if ($this->_identity === null) {
$this->_identity = new UserIdentity($this->email, $this->password);
$this->_identity->authenticate();
}
if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
$duration = $this->rememberMe ? 3600 * 24 * 30 : 3600; // 30 days or 1 hour
Yii::app()->user->login($this->_identity, $duration);
return true;
}
else
return false;
}
If someone needs need some extra info just let me know.
Thank you in advance.