Difference between #5 and #6 of
How to add more information to Yii::app()->user

Revision #6 has been created by Maurizio Domba Cerin on Feb 7, 2012, 11:41:57 AM with the memo:

added tags, changed interaface IUserIdentity to class CUserIdentity to get proper link
« previous (#5) next (#7) »

Changes

Title unchanged

How to add more information to Yii::app()->user

Category unchanged

Tutorials

Yii version unchanged

Tags changed

CWebUser, authentication

Content changed

By default, the expression Yii::app()->user returns a [CWebUser] [application component](http://www.yiiframework.com/doc/guide/basics.application#application-component) which represents the information that are closely related with the current user. Some information can be persistent throughout the current user session. For example, [CWebUser] already comes with a [name|CWebUser::name] property that stores the username of the current user. In order to store more information, we need to modify the [identity|ICUserIdentity] class used together with [CWebUser]. Each application may have one or several identity classes which are mainly responsible to provide ways of performing user [authentication](http://www.yiiframework.com/doc/guide/topics.auth).

Here we use the `UserIdentity` class included in the `testdrive` application as an example, assuming our goal is to add the ID and the last login time of the user to [CWebUser]. We would modify `UserIdentity` as follows,


```php
[...]
21 0
28 followers
Viewed: 226 787 times
Version: 1.1
Category: Tutorials
Written by: qiang
Last updated by: Yang He
Created on: Feb 9, 2009
Last updated: 11 years ago
Update Article

Revisions

View all history