yii::app()->user->setState()

Hi everyone!

I’m trying to save an email address into yii::app()->user->email only if it was not set yet.

How do I check if it was set and if it was don’t set it?

Hi,

try this way:




if(!Yii::app()->getUser()->hasState('email'))

    Yii::app()->getUser()->setState('email','email@example.com');



cheerio

Worked like a charm. Didn’t know there was even such a thing as hasState()

Thanks for enlightening me.