previously before i change the domian in session.php,my Auth::login() is working fine and it will persist the cookie so they dont need to login again. When some of my friend told me that when they click login (from facebook), it will somehow return InvalidStateException in AbstractProvider.php.
I google around knew there maybe some issue cause by the cookie, and the solution is changing the domain in the session.php from null to my domain (example myapps.com).
After i've change to the myapps.com, invalidstateException no longer occurs but it wont persist my login. After a 6 - 12 hours, it required me to login again.
Below is my code ( i believe my code is correct just after i've change the session and the login wont persist anymore).
$UserLogin = User::where('facebook_id', '=', $user->getId())->first();
Auth::login($UserLogin, true);
The core problem is that your browser stores two cookies from multiple domains with the same cookie name called
laravel_session
; when you make a request, both cookies with the same name are sent to the server.In your
config/session.php
:By changing the name of the
cookie
anddomain
, you'll get around the problem by the storing new cookies under a new name.