How To Add More Information To Yii::app()->User


in this Wiki

we have this code

class UserIdentity extends CUserIdentity


    private $_id;


    public function authenticate()





        else if($user->password!==md5($this->password))





            $this->setState('lastLoginTime', $user->lastLoginTime);



        return !$this->errorCode;



    public function getId()


        return $this->_id;



I want to know , Just lastLoginTime will save in Cookie if allowAutoLogin==true , Or both $_id and lastLoginTime will save in Cookie if allowAutoLogin==true

I want to create these class

For FrontEnd

class FrontEndIdentity extends CUserIdentity{

 public $isAdmin = false;


For Backend

class BackEndIdentity extends CUserIdentity{

  public $isAdmin = true;


and in use Yii::app()->user->isAdmin to detect admin , Is it SAFE ??

(I save admin and user information in deferent Database table and may be admin and user have equal ID)

  1. both states will be saved in cookie for auto login

  2. CUserIdentity is NOT what is visible under Yii::app()->user. in order to extend this component and add "isAdmin" attribute you need to to extend also CWebUser and configure applicatio to use instead of the default class.

ok thanks