Symfony2 and “ContextErrorException: Warning: SessionHandler::read()” Exception

I just upgraded to Symfony 2.4, and started randomly getting this error:

ContextErrorException: Warning: SessionHandler::read(): open(/var/lib/php/session/sess_3cq63tff1lhbghus3o9jsh26j4, O_RDWR) failed: No such file or directory (2) in /var/www/ line 69

Which was pretty odd, as there is a discussion about this, which you can find here on symfony/symfony github, However the issue seems to be in part with PHP, but it was for me already patched. As the issue is introduced in 5.4 somewhere and fixed in 5.4.11.

It seems that everything was fixed, and i was many versions ahead. So why was this cropping up randomly now? I had not changed my PHP version or my OS version, just symfony.

It seems some config changed, which i show below. If you do not have this set, then i believe it falls back on the default php.ini setting of session.cookie_path, which if blank causes this. Add this config below will fix the issue.

I hope this helps.

9 thoughts on Symfony2 and “ContextErrorException: Warning: SessionHandler::read()” Exception

  1. This is exactly what I needed to make it happen on my Mac OS build. Funny thing is that this error started appearing after I changed the user that PHP runs under from _www to staff user. Thanks again

  2. Pingback Symfony2 and “ContextErrorException: Warning: SessionHandler::read / write – Symfony Venezuela
  3. sorry, i’m newbie here. Where i can find php.ini in server?

Leave a Reply