Chrome losing partial session data?

I have a function in the main Controller that does this:

public function delayMessage($msgText)


	$session = Yii::app()->session;

	if (!isset($session['messages'])) {

		$msgs = array($msgText);

	} else {

		$msgs = $session['messages'];

		$msgs[] = $msgText;


	$session['messages'] = $msgs;


And another one for errors that just uses the ‘errors’ key instead of messages. The purpose of this is to store messages to the user if the controller needs to redirect(). On init() the core Controller class looks at the session for messages and errors, and displays them accordingly.

Now, in Firefox or Opera, it works. it just plain works. Doesn’t matter what the redirect() URL is, doesn’t matter what the message is, it just plain works.

Chrome, however, is a different story. It… just plain doesn’t work.

I can confirm that, right up until the exact moment before redirect(), “Yii::app()->session[‘messages’]” will in fact have exactly the contents it should.

But when the page redirects… it’s gone. Right from the moment of page initialization. I even print_r’d the array. The user’s login is fine. Just the ‘messages’ and ‘errors’ indices (and possibly anything else I would set manually) are gone. Which is downright baffling, because I was under the impression that session data was all server-side.

Does anyone know what the problem could be, and why it only affects Chrome?

As you already said, any session data is kept on the server side. All the browser knows is the session ID (in a cookie) which it sends with every request. Since sessions seem to work even in Chrome, you must have missed something in your logic.

I found the problem, and it is indeed browser-side - but not browser-specific.

Just the other day, I changed the site’s session cookies so that it would stop breaking if users added ‘www’ to the address. So it created a new session cookie… but the old one is still alive and active anywhere that it will work (basically, any page on my site without the ‘www’), for any user who was logged in at the time. Yii is actually storing the data in one version of the session, but retrieving it from the other, causing it to seem like the data just went away. Logging out and back in didn’t work, because it just affected one of the sessions. Firefox had apparently not been opened recently (or I wasn’t logged in during the cookie transition), so it only has a single cookie, and a single session.

I can only assume that if I wipe the session table, it will be fixed for everyone, though they’ll have to log in again.