UserIdentity.php
<?php
/**
* UserIdentity represents the data needed to identity a user.
* It contains the authentication method that checks if the provided
* data can identity the user.
*/
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->check($this->password))
{
$this->_id=$user->id;
$this->username=$user->username;
$this->setState('lastLogin', date("l jS F Y \@\ g:i A", strtotime($user->last_login_time)));
$user->saveAttributes(array(
'last_login_time'=>date("Y-m-d H:i:s", time()),
));
$this->errorCode=self::ERROR_NONE;
}
else
$this->errorCode=self::ERROR_PASSWORD_INVALID;
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
then in view/admin:
<?php if(!Yii::app()->user->isGuest):?>
<div class="flash-success">
Welcome Back. You last logged-in on <?php echo Yii::app()->user->lastLogin; ?>.
</div>
<?php
Yii::app()->clientScript->registerScript(
'fadeAndHideEffect',
'$(".flash-success").animate({opacity: 1.0}, 5000).fadeOut("slow");'
);
endif; ?>
I want the message like;
Welcome Back User (username of the user). You last logged-in on Friday 30th August 2013 @ 7:45 PM.
EDIT
Solution:
<?php if(!Yii::app()->user->isGuest):?>
<div class="flash-success">
Welcome Back <b><?php echo Yii::app()->user->getName(); ?>.</b> You Last Logged-in on <b><?php echo Yii::app()->user->lastLogin; ?>.</b>
</div>
<?php
Yii::app()->clientScript->registerScript(
'fadeAndHideEffect',
'$(".flash-success").animate({opacity: 1.0}, 10000).fadeOut("slow");'
);
endif; ?>