laravel login with load balancer gives 419 page expired error
I have created 2 Laravel projects (both are same) and running in separate digital ocean droplets under a Digital Ocean load balancer.
When I access the web page with load balancer IP, it works fine but in the login page it gives me a 419 page expired error. When I try the servers separately, it works without an issue.
I've gone through some articles and found out the session created at the login redirects to the next server because of the load balancer.
Is there anyone who can help me to fix this issue?
I just looked up the Laravel documentation for database session driver as @jlrdw and @lucasantonio mentioned.
Change the session_drive=file to session_drive=database in .env file.
then run these commands:
php artisan session:table
php artisan migrate
Now the sessions are stored in database instead of individual servers.
It fixed the conflict!
@jlrdw Hi, I know it's late to join this conversation, but after changing session_drive=file to database, do I need to change the 'database' value in anywhere else such as config file, etc. ?