Add extra attributes to Yii::app() -> user

Hi

Hopefully this is an easy question. I was wondering if it were possible to add extra attributes to Yii::app() -> user so it can contain other data other than just username and user id.

I did a quick search, couldn't find anything so I aplogise if its been asked before.

Thanks

Chris

Hi,

Do you mean this?

http://www.yiiframew…doc/cookbook/6/

Greetz

Yes I do, thank you :)

One follow up question.

Can a sate be updated during a session, for example:

User logs in -> sate x set to 1 -> user does something -> state x changes to 0 for the rest of the session

Been having a play, haven't been able to do it yet.

Chris

The following line should work (for 1.0.3):

Yii::app()->user->stateName=something;

Thank you.

I'm not sure how to do one thing. Id like this state change to happen automatically when the application is run. The idea is it would get some data from the database and alter the state according to this data.

I'm not sure how I would go about this.

Thanks for your help :)

Chris

[edit]

I should also say I have tried doing this in my writeSession override but it doesn't seem to be altering the state so that it is used by the rest of the application.

You may refer to the idea in this post.