Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ArthurGuy's avatar

L5.1 Cookie session failing

Hi all, I am migrating a 4.2 site to 5.1 and I am having trouble storing session data using the cookie driver.

I am passing form validation errors in the session for display on the front end, the problem is this doesn't work at all for the cookie driver. If I switch to a file driver everything works perfectly.

Is there a known change in behaviour or perhaps a bug which might be causing this to fail?

If I dump out the contents of the session I get the following but I can't add any of my own data to it.

Array ( [_token] => FTWmSVLUuUndscAKu0iohd7JSSbG1IeBO6rSSHi8 [_previous] => Array ( [url] => https://bbms.buildbrighton.dev/password/forgotten ) [flash] => Array ( [old] => Array ( ) [new] => Array ( ) ) )

Anyone got any advice?

I had to go straight to 5.1 because I needed middleware parameters

0 likes
5 replies
mstnorris's avatar

I didn't read through the whole thing but a few of people mentioned "cookie" throughout.

ArthurGuy's avatar

I did come across that thread when looking into the problem and it seems to be unrelated, I think that's more about sessions getting occasionally reset

ArthurGuy's avatar

After a bit more looking it seems that cookie based sessions are fine until an exception is thrown.

If I throw an exception and handle it in the exception handlers render method then cookie based sessions get destroyed.

Please or to participate in this conversation.