我是Yii框架的新手。我在Yii论坛上问过这个问题,但没有得到任何好的结果,所以我来到了这里。其实我想在管理员登录时显示上次登录时间。它在Yii用户模块中可用。那么该怎么做。是否有可能从用户模块到索引页面获得这些时间?任何帮助和建议都将非常可观。在Yii框架中获取最后登录时间
[更新]
我跟着this link,我犯了这样的UserIdentity代码为每条指令:
class UserIdentity extends CUserIdentity
{
private $_id;
public function authenticate()
{
$user=User::model()->findByAttributes(array('username'=>$this->username));
if($user===null)
$this->errorCode=self::ERROR_USERNAME_INVALID;
else if($user->password!==md5($this->password))
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
{
$this->_id=$user->id;
$this->setState('lastLoginTime', $user->lastLoginTime);
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
现在我要打电话id
和lastlogin
鉴于文件,这样就可以得到lastlogin time.So我已经在视图文件中使用了这段代码。
<?php echo Yii::app()->user->name;?>
<?php echo Yii::app()->user->lastLoginTime;?>
所有更改后,我得到了像错误:
Property "CWebUser.lastLoginTime" is not defined.
我在视图文件中做了它,但它显示了像这样的错误解析错误:语法错误,意外的T_VARIABLE。 – NewUser 2011-12-30 08:29:38