On my project's configuration file I have:
session:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
"%kernel.root_dir%/../var/sessions
belongs to wwww-data
(and yes, php-fpm is running as www-data
).
When the project runs, an (empty) session file is created in that dir, but apparently php/symfony have trouble actually reading/writing to it, despite being able to properly create it. Here's the empty session file, just created (no other process ran after this request):
The request dies raising an exception:
Session data file is not created by your uid.
I found this answer (and this one), and by doing that (setting my session's save_path
to "/var/lib/php/sessions"
I'm able to continue (and I can see that my session files get not only created, but that its contents are actually in place), but I'm trying to understand why it fails to save the session files on the custom location.
In my PHP configuration I see that I have session.save_path
set to /var/lib/php/session
, but I'd expect I'd be able to override that on execution time.
What really peeves me is that the session file get created (so file permissions should be fine), but not written into.
I'm running Symfony 3.2.2 on top of nginx + php-fpm (7.0).
Why is this happening? Is there any other setting I should use so php is able override this configuration and write its sessions files elsewhere?
From the trace I see that:
NativeSessionStorage ->start()
is called, and executessession_start
(which returns true)- Then
SessionHandlerProxy ->read($sessionId)
is called, and throws the exception when calling$this->handler->read($sessionId);
.