Laravel 5.2 session lost after successful login, sometimes

182 Views Asked by At

When trying to access a protected route or just refreshing the page the session is lost, so I have to login again. What I don't understand is that sometimes this problem does not happen but most of the time it does and sometimes it takes more than 3 times of doing the login before I can finally access a protected route. This only happens in production. I have no idea but it started only after I moved my hosting to Cloudways and users start complaining.I have other Laravel app with version 5.4 on the same server without problems.

1

There are 1 best solutions below

1
On

1- change your session driver value to database then the user's session will be stored inside your database, sessions table instead of file:
in your .env file set :

SESSION_DRIVER=Database

2- clean cache and config

php artisan config:clear
php artisan cache:clear