I want to save some details on session when the user login. And the details are retrieved from the same user table that user for Auth(). Do I have to query again after login and set the session variables or there is a way within auth. Thanks in advance! :)
You can get the currently logged in user with Auth::user(). So, if you wanted to store the user's username in the session after login you could do this:
$user = Auth::user();
Session::put('username', $user->username);
To store user information, You can easily use
$user = Auth::User();
Session::put('user', $user);
$user=Session::get('user');
return $user->name;
You must have to put use Session; in controller where you want to set or get the value
here $user is a object you can get all other property using this -> sign.
Thank You
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