php – Laravel autologin


The situation is like this:

The user is added manually in the admin panel, a letter is sent to his mail, which he follows, completes the registration and his login.

The problem is this:

Laravel logs in the user, but when redirecting, the browser behaves as if there was no autologin and forces the user to log in manually.

The auto login code is as follows:

Auth::login($user, true);
$isLogin = Auth::check(); //true
$user = Auth::user(); //Valid user instance

Before that, it was tested:

auth()->guard()->login($user, true);

The result is the same.

I forgive help.

UPD . Laravel v5.5


The problem was with the session. The session()->flush() call solved the problem.

Scroll to Top