I am new to laravel and I am working with a functionality where we insert data in user table with
DB::insert();
After that i get last id with
$user_id = DB::getPdo()->lastInsertId();
Now I want user to login after register and I am trying to
Auth::loginUsingId($user_id);
But its returning me false. I also tried
$user = User::find($user_id);
Auth::login($user);
Its also return null $user.
Please help...
Login User:
Auth::login($user);
check current user is login or not:
Auth::check();
This worked for me
Auth::loginUsingId(1);
Auth:login
returns void
so you can try something like this to check if user is logged in or not:
Auth::login($user);
return [
'status' => Auth:check()
];
check()
determine if the current user is authenticated or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With