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

DonSchoeman's avatar

File session on top of Homestead + NFS is partially broken.

Today I ran into a weird issue where session data would randomly get lost between redirects. I eventually tracked it down to using a File session driver over a shared drive between my host machine and a Homestead box. I've opted to use NFS to speed up the mapped drive so I'm not sure if this happens with the standard network mapping as well.

I think the problem is caused due to a race condition in that the new page is redirected to and requested by the browser before the session is written to file, hence the randomness of it all. Changing the session and cache driver to memcached for example solves the problem.

I'm a seasoned developer (new to Laravel though) so I was able to solve the problem within minutes, but a beginner would potentially struggle for hours or even days given the inconsistency of the problem. Is there a way that perhaps new sites generated with the laravel new command could configure the default "file" cache and session driver with memcached or redis in the .env file? If not, then the issue I think should be displayed more prominently somewhere.

0 likes
2 replies
sdbruder's avatar

Im using homestead with NFS, too, using the default config for sessions in homestead, file driver in /var/lib/php5/sessions, outside of the NFS mount point, with no issues at all.

You need to do it in the NFS ?

DonSchoeman's avatar

The problem is that different hardware configurations may or may not cause issues. For example, your HDD and CPU speed may determine whether you have this problem or not, and that makes the situation very hard to resolve. One could of course fix it by moving the session files to a non-shared directory on the Homestead box all together, but using a different session driver is still better a better option in my humble opinion.

Please or to participate in this conversation.