In this tutorial im going to learn how to print user email and password get using session in laravel for login user. Sessions are used to store information about the user across the requests. Laravel provides various drivers like file, cookie, apc, array, Memcached, Redis, and database to handle session data. By default, file driver is used because it is lightweight. Session can be configured in the file stored at config/session.php.
1st step go to logincontroller and put below function
protected function attemptLogin(Request $request)
{
Log::info("anhi to aaye hai");
$credentials = $this->credentials($request);
// Apply your custom logic to validate the hashed password
$user = User::where($this->username(), $credentials[$this->username()])->first();
if ($user && Hash::check($credentials['password'], $user->password)) {
$this->guard()->login($user, $request->filled('remember'));
// Store email and password in the session
session(['email' => $credentials['email'], 'password' => $credentials['password']]);
return true;
}
return false;
}
2nd step go to blade page and put below code
<h2>Email: {{ Session::get('email') }}</h2>
<h2>Password: {{ Session::get('password') }}</h2>
@php
$email = Session::get('email');
$password = Session::get('password');
@endphp
Output:-