Why gives this error?
[b]
[/b]
Fatal error: Call to a member function setStateKeyPrefix() on a non-object in
if (isset(Yii::app()->user))
Yii::app()->user->setStateKeyPrefix("_{$this->id}");
Why gives this error?
[b]
[/b]
Fatal error: Call to a member function setStateKeyPrefix() on a non-object in
if (isset(Yii::app()->user))
Yii::app()->user->setStateKeyPrefix("_{$this->id}");
You can try:
if (isset(Yii::app()->user) && (Yii::app()->user instanceof CWebUser))
Yii::app()->user->setStateKeyPrefix("_{$this->id}");
But anyway your code should work, because even if user is guest, he should be still instance of WebUser.
Or maybe you’ve changed the user component in your main config or it isn’t configured at all?
Is configured, and I have the standard WebUser.
what is strange that this happens only at first time when I access the project, eg: probably when session is restored from cookie
No matter if user is restored from session or just authenticated by username/password, both process should be finished, and user component should be available at that time.
Did you try code I suggest, do you get same output?
I added the code, and now I am waiting to get tested.