Auto Login after Registration in Laravel
Today we are going to see how we can make auto login when the user is registered in laravel so let's see how we can do that.
Make Auto Login after Registration
All you need to do is when you get the data from the form in your controller and the user is created, you retrieve the new user and use the Auth login method to make the auto login.
public function store(Request $request){
$this->validate($request,[
'name' => 'required|max:100',
'email' => 'required',
'password' => 'required|min:6'
]);
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
auth()->login($user);
return redirect('/');
}