yii框架,设置自动登录以后,怎么捕捉登录动作?

dropme 2012-05-27 09:07:35
用的yii,实现了自动登录。现在的问题是,需要在用户登录的时候,记录下登录时间,请问应该在哪里做呢?
我现在是在component的 useridentity类下的authenticate方法里,记录用户登录时间的,但是貌似会漏掉。用户选自动登录的时候,有的时候貌似记录不到。

大大们,应该怎么弄啊?
...全文
300 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dropme 2012-05-28
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

大概是yiilite.php文件中的以下几行代码实现的自动登陆。我想你能看出原因来
PHP code

public function init()
{
parent::init();
Yii::app()->getSession()->open();
if($this->getIsGuest() && $this->a……
[/Quote]

哥哥,我是菜鸟啊,刚学php,这个确实看不懂~应该怎么解决呢?
coder 2012-05-27
  • 打赏
  • 举报
回复
大概是yiilite.php文件中的以下几行代码实现的自动登陆。我想你能看出原因来

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 be set true in order to use cookie-based authentication.',
array('{class}'=>get_class($this))));
}
$this->afterLogin(false);
}
}


4,250

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧