How to use userIdentity variable in another form

else {

$this->_id = $user->id;

$this->_userType = 2;

$this->username = $user->user_name;

$this->errorCode = self::ERROR_NONE;

}

how could i refer the value userType in another forms after login

eg(Yii::app()->user->id) what i should do to take user type and name?

Maybe you can refer with Yii::app()->user->identityCookie, but I am not sure.

Another option is to save this data in Yii::app()->user->setState(‘userName’, $user->user_name) and receiving with Yii::app()->user->getState(‘userName’).

zaccarias second approach is the way it should be done. Read this section from the guide and check out the example (especially how ‘title’ is saved):

http://www.yiiframework.com/doc/guide/1.1/en/topics.auth#defining-identity-class

Thank you mike for the pointing this resource!

I short, it looks like that is possible in the UserIdentity to do something like:




$this->setState('userType', 2);



And this state will be passed to web user, wich can be accessed with:


Yii::app()->user->getState('userType');

Or


Yii::app()->user->userType;

Let us know if it works properly!

Its given clearly in that documentation zaccaria(Thanks Mike and zaccaria)

Yii::app()->user->title (This has been available since version 1.0.3. In prior versions, one must instead use Yii::app()->user->getState(‘title’).)