Difference between #1 and #9 of
Add information to Yii::app()->user by extending CWebUser

Changes

Title unchanged

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

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

Content changed

This little tutorial explains a way how you can retrieve more parameters from **Yii::app()->user** by adding a component that extends **CWebUser** and retrieves the user information from database table named User. There is also another method of doing this that retrieves the variables from session or cookie instead: [How to add more information to Yii::app()->user (based on session or cookie)](http://www.yiiframework.com/doc/cookbook/6/) **Steps to follow:** 1. Make shure you have got an database User model.
2. Create a component that extends CWebUser.
3. Specify in the config.php what user class the application must use.
[...]
```php
// you must edit protected/config/
configmain.php
// and find the application components part
// you should have other components defined there
[...]
Yii::app()->user->first_name - property that returns name
Yii::app()->user->isAdmin() - function that returns admin status
And now you can add all the functions you want to WebUser component.

 
27 0
38 followers
Viewed: 151 512 times
Version: 1.1
Category: Tutorials
Tags:
Written by: atrandafir
Last updated by: Yang He
Created on: Jan 10, 2010
Last updated: 11 years ago
Update Article

Revisions

View all history