Hello!
As the title says, I'm facing problems with maintaining session over multiple subdomains. I tested this with both my existing project and a fresh Laravel 5.7.19 installation, both with the same results.
What I want: login on domain 1, say login.localhost, and then maintain that authenticated state on all other subdomains (portal.localhost, manager.localhost etc).
The problem: At the beginning, a successful login would return me to the login page, because the session was not sustained between two subdomains (login and portal). After an internet search I cleared the cookies in Chrome. After clearing the cookies, this new problem appeared: upon POSTing to the Authentication script, a 419 Expired error occurs. Closer inspection tells that the session is reset on every page load.
Solutions tried:
- tested this both on my local Windows environment and Linux server, same results
- set the SESSION_DOMAIN to .localhost in .env
- tested with multiple drivers (database, cookie, file)
- updated all dependencies and cleared application and configuration cache
- changed the $domain in CookieJar.php's make function to env('SESSION_DOMAIN')
All of the above didn't fix my issue.
Would anyone be able to help me?