I ve been developing a facebook application on Yii and after the authentication i want to set the username and id according to the facebook username and id. As i am new to Yii I dont’t have much idea about how to do it. Though when i tried to set the user id in my UserIdentity class, it gave an error saying that
Property "UserIdentity.id" is read only.
is there any other way to do it?
What are you using for authentication now? If you set up a webapp you should have a UserIdentity class in components that extends CUserIdentity. This is usually where you would use setState(), like
$this->setState('first_name', $record->first_name);to set the user’s first name from a db record after authentication, as an example, which you can retrieve viaYii::app()->user->first_nameHowever, I think what you may be looking for is
Yii::app()->user->name = 'newname';which changes the CWebUser property that CUserIdentity sets during authentication with the CUserIdentity::username value.Either option is fine — setting a custom Yii::app()->user->value or resetting the Yii::app()->user->name value, whichever works best for your app. (I wouldn’t reset the user->id value tho.)