Reputation: 1542
With an upgrade to from PHP5.6 to PHP7, I am confronted with this error:
sapi_apache2.c(326): PHP Warning: session_write_close(): Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/var/lib/php/7.0/session)
This is odd, because we use a custom session handler, which writes to a database.
What changed in PHP7?
Upvotes: 2
Views: 11323
Reputation: 1542
The PHP warning is misleading in this situation, because the session is not writing to that directory.
PHP7 is stricter than PHP5.6 when evaluating the return value of the custom session handler. If that write method returns back FALSE, it will trigger this warning when calling session_write_close. See: PHP write-session documentation.
So the solution here is to always return back TRUE from the write-session method. If there is an error, it is probably best managed through exceptions, not a return value.
Upvotes: 7