Difference between #5 and #8 of
Add information to Yii::app()->user by extending CWebUser (better version)

Changes

Title unchanged

Add information to Yii::app()->user by extending CWebUser (better version)

Category unchanged

Tutorials

Yii version unchanged

Tags changed

Yii, user, rbac

Content changed

[...]
class WebUser extends CWebUser
{
public function __get($name)
{
if ($this->hasState('__userInfo')) {
$user=$this->getState('__userInfo'
,array());
if (isset($user[$name])) {
return $user[$name];
[...]
public function login($identity, $duration) {
$this->setState('__userInfo', $identity->getUser
info()->attributes()); parent::login($identity, $duration); }  
 
/* 
 
* Required to checkAccess function
 
* Yii::app()->user->checkAccess('operation')
 
*/
 
public function getId()
 
{
 
return $this->id;
 
}

}
?>
```

remember to set that class as Yii::app()->user class:
[...]
5 0
10 followers
Viewed: 50 294 times
Version: 1.1
Category: Tutorials
Tags: rbac, user, Yii
Written by: emix
Last updated by: Anas AbuDayah
Created on: Aug 15, 2010
Last updated: 10 years ago
Update Article

Revisions

View all history