[SOLVED] Unexpected keys for $_SESSION and Yii::app()->session

Hi, I didn’t modify anything dealing with session setup, so in my Yii config sessions are started automatically.

I was trying to get session values for key ‘name’, but looking at the session file stored in /tmp on the server I see that ‘name’ key I was looking was indeed ‘46278e760e264a62c85bf2e34ce11cfc__name’ so I had to do

$session = Yii::app()->session->get('46278e760e264a62c85bf2e34ce11cfc__name');

to get the ‘name’ value.

All the keys are stored with ‘46278e760e264a62c85bf2e34ce11cfc__’ preceding the meaningful name.

Why is it like this? Is this a safety measure? How can I get this prefix programmatically or how can I stop Yii using this prefix?

[size="2"]Check did someone called [/size]setStateKeyPrefix() function somewhere in code (index.php, or base controller or similar bootstraping files).

[color="#222222"][font="Arial, sans-serif"] [/font][/color]

[font="Arial, sans-serif"][color="#222222"][size="2"]setStateKeyPrefix() - [/size][/color][/font][color="#222222"][font="Arial, sans-serif"][size="2"]Sets a prefix for the name of the session variables storing user session data.[/size][/font][/color][color="#222222"][font="Arial, sans-serif"][size="2"][i]


Thanks, I didn’t know what it was… The stateKeyPrefix

I’m looking at the api refference:


“46278e760e264a62c85bf2e34ce11cfc__” seems to me an user specific prefix. And you don’t have to (or, should not) touch it.

Probably you just have to "open" the session before accessing the session variables.


Let me know if the problem is solved ;)

Oh yes, the problem is SOLVED!

Please share with us what the problem was, so we can help to anyone in the future.