In this tutorial im going to learn how to retrieve user id and user email using session in laravel.
First go to LoginController and put below code
if (auth()->attempt($credentials)) {
// Authentication successful
$user = auth()->user();
// Store user information in session
session(['user_id' => $user->id, 'email' => $user->email]);
return redirect()->intended('/dashboard');
}
Next go to blade page to show the user_id and email using session
$userId = session('user_id');
$email = session('email');
Next go to blade page put above code as well
@php
$email = Session::get('email');
$password = Session::get('password');
@endphp