How to Get Logged in User Data in Laravel?

By Hardik Savani November 5, 2023 Category : Laravel

Hi Artisan,

This article goes in detailed on laravel get logged in user details. you will learn laravel get logged in user data. This post will give you a simple example of laravel get current user. This example will help you laravel get logged in user.

If you are beginner or don't know how to get logged in user details in laravel 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

Laravel Get Logged User Data using auth() Helper

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

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

print_r($user);

Laravel Get Logged User ID using auth() Helper

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

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

print_r($id);


Laravel Get Logged User Data using Auth Facade

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

$user = Auth::user();

print_r($user);

Laravel Get Logged User ID using Auth Facade

you can get login user id using Auth facade, it will also return user id.

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

print_r($id);

I hope it can help you...

Tags :
Shares