Some Sessions Not Stored

Hi all!

Im having a issue i just found with my Authentication.

When the user logs in, i save a few sessions:


Yii::app()->session['id'] = $user->id;

Yii::app()->session['name'] = $user->name;

Yii::app()->session['email'] = $user->email;

And this works fine, the name displays at the top.

But when the browser is closed and reopend the loginstate remains true (Yii::app()->user->isGuest returns FALSE)

but the name and email is no longer stored.

Why is this? How can i slove that?

Thank you!

Try to use state instead:




Yii::app()->user->setState('id', $user->id);

Yii::app()->user->setState('name', $user->name);

Yii::app()->user->setState('email', $user->email);



Should be available next time unless you logout.

You can retrieve your stored state as follow:




Yii::app()->user->getState('id');

Yii::app()->user->getState('name');

Yii::app()->user->getState('email');



[size=2]Thank you. That did not help, but the error was wrongful authentication.[/size]

Sorry for wasting your time :) Have a good day.

[size=2]I’m having the same problem, when I use “Remember me” it keeps the session when I close the browser but my “setState”'s are not saved.[/size]

Can you share your solution? :P

Please consider the default session time in the server. And rewrite according to your wish.

Thanks for your reply. Fixed it.

Changed session.cookie_lifetime on php.ini, it had 0 as default.