Intermittent session data loss with database driver
My application is showing some worrying problems that only happen with the database session driver.
Sometimes when I redirect with errors, the flash data in the session is lost. This only happens when using the database session driver, changing it to the file session driver fixes the problem.
The specific scenario is as follows. On my local box I have functionality that resets passwords. Sometimes when I enter an email but no password, it displays no errors. Other times it correctly shows the error message "password is required" I've confirmed that the validator is indeed generating an error, and that the error is getting passed to redirect()->withErrors() in ValidatesRequests.php, but sometimes the errors just poof vanish.
This doesn't always happen. It normally happens if I attempt to reset my password within a few seconds of clicking on the reset link. It also doesn't happen if I run the code in the debugger (xdebug), or add too many print() statements.
The fact that the problem is intermittent and is affected by running it in the debugger / with print statements suggests that it may be due to either a race condition or memory corruption.
My system is Laravel 5.1, Ubuntu 15.10, Postgres 9.4.5, nginx 1.9.3, PHP 5.6.11-1ubuntu3.1 (fpm-fcgi)
Ordinarily the solution would appear to be to use the file driver, but this is not possible since the filesystem on heroku is temporary.
Thanks for any suggestions anyone might have.
Please or to participate in this conversation.