authentication - Laravel 5.2 Auth::login($user) not working -
i writing laravel 5.2 application. need manually login user using \auth::login($user)
. doing in following way.
if ($user = user::where('phone',session('phone'))->first()) { \auth::login($user); // \auth::loginusingid($user->id); // auth::attempt(['email' => $user->email, 'password' => 'password']); $data = \auth::user(); //returning correct results }
i have tried options namely auth::login($user)
, authh:loginusingid($user->id)
, attempt
method. these methods working fine $data variable storing object of correct user. problem when move other route '/home'
user remain no more authenticated.
what might wrong here? how correctly?
since laravel 5.2, have attach routes need session the 'web' middleware. see app/http/kernel.php, 'web' middleware contains \illuminate\session\middleware\startsession.
Comments
Post a Comment