Yii framework, after setting up automatic login, how to capture the login action?
The use of yii, the implementation of automatic login. Now the problem is that you need to log in when the user logged in time, where should I do it?
I am now in the Authenticate method under the Useridentity class of component, recording the user login time, but seemingly will miss out. When users choose to log in automatically, sometimes it seems that they are not logged.
How do we do that, big boys?
------Solution--------------------
This is probably the following line of code in the yiilite.php file for automatic login. I think you can see why.
Public function init ()
{
Parent::init ();
Yii::app ()->getsession ()->open ();
if ($this->getisguest () && $this->allowautologin)
$this->restorefromcookie ();
else if ($this->autorenewcookie && $this->allowautologin)
$this->renewcookie ();
if ($this->autoupdateflash)
$this->updateflash ();
$this->updateauthstatus ();
}
Public Function login ($identity, $duration =0)
{
$id = $identity->getid ();
$states = $identity->getpersistentstates ();
if ($this->beforelogin ($id, $states, False))
{
$this->changeidentity ($id, $identity->getname (), $states);
if ($duration >0)
{
if ($this->allowautologin)
$this->savetocookie ($duration);
else
throw new CException (Yii::t (' Yii ', ' {Class}.allowautologin must is set true in order to use cookie-based Authentica tion. ',
Array (' {class} ' =>get_class ($this)));
}
$this->afterlogin (false);
}
}