How to get logged in user data in Laravel 5?

By Hardik Savani | May 25, 2016 | | 55681 Viewer | Category : Laravel


If you are beginner or don't know how to get logged in user details in laravel 5 application then you can do it using laravel auth helper. Laravel can get current login user data both way one using auth helper and another Auth facade. In this post you can learn how to get current logged user id. so first yo

Get Logged User Data using helper

you can get login user details using auth() helper, it will return object of users details.

$user = auth()->user();

print_r($user);

Get Logged User ID using helper

$id = auth()->user()->id;

print_r($id);


Get Logged User Data using facade

you can get login user details using Auth facade, it will also return object of users data.

$user = Auth::user();

print_r($user);

Get Logged User ID using facade

$id = Auth::user()->id;

print_r($id);




Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.