Don't forget the helper function auth()->user(), my favorite ☺
I guess you could say they are different ways to get the same thing.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
It seems as though you can retrieve the current authenticated user via the Auth facade or via the Request...
$user = $request->user();
// or...
$user = Auth::user();
Is there a difference between these methods? Or is it pretty much the same?
Don't forget the helper function auth()->user(), my favorite ☺
I guess you could say they are different ways to get the same thing.
Unfortunately the advantages of one or the other depends. The request, from my understanding logging queries, doesn't run a query but may have stale data. I know auth does query the db on each request, though it does it anyways.
Also a more fluent/readable approach instead of having a random auth()->user() in an array of $requests seems out of place.
I am experiencing a problem where
Auth::user();
returns user A from a browser firefox, even when its incognito. Yet i am using another chrome incognito to view another user account logged lets say user B but still returns user A.
However when i use
$request->user();
in the same place as the first instance i get expected results. Two different users in the respective browsers above.
I have done a check experiment by using Microsoft edge to log into a third user account. The results still hold as i switch the code blocks above.
1.What causes this problem or is this feature or am i miss using the tool?
@ssempebwa start a new discussion
$request->user() returns an instance of the authenticated user.
@dawood Why did you bump a year-old thread to say very little?
@martinbean Value is value, I dont understand why do you have problem with that ? have seen you doing it alot.
@saeeddirect where would we be if everyone started posting bits from the documentation on every old post? This thread is actually 5 years old and contains dated information.
@Snapey I don't think that it contains dated information. Someone who lands on this page from google would find it helpful. Laravel docs for 9.x say:
Alternatively, once a user is authenticated, you may access the authenticated user via an Illuminate\Http\Request instance. Remember, type-hinted classes will automatically be injected into your controller methods. By type-hinting the Illuminate\Http\Request object, you may gain convenient access to the authenticated user from any controller method in your application via the request's user method
Link: https://laravel.com/docs/9.x/authentication#:~:text=Alternatively%2C%20once%20a,method%3A
@saeeddirect Because people keep bumping ~5 year old threads with stupid responses like, “did you find answer?”, “I have same issue”, etc. There’s absolutely no value in replies like that.
@martinbean yes, "dawood" actually answered correctly just in case so that people won't post "did you find the answer". peace.
@saeeddirect The question was
Is there a difference between these methods? Or is it pretty much the same?
"dawood" just stated one of the options === waste of time
@22289d feeling better now?
@22289d And you wasted my time by tagging me and making me read that completely useless reply. So let’s call it even 🙃
Hello! I have made some tests in an empty Laravel project. Laravel version is 9.30.
If the user is authenticated the Laravel determines it by session and makes an SQL query like:
SELECT * FROM `users` WHERE `id` = 12 LIMIT 1
The SQL query executes in any way, by default, under the hood. The Laravel creates User object. The request()->user(), auth()->user() and Auth::user() just return the same User object without additional queries to the DB. In example Auth::user() === request()->user() returns true etc.
So feel free to choose the method.
@woodgas Yes, if the authenticated user has already been retrieved in the current request then Laravel won’t bother re-querying the database again:
Please or to participate in this conversation.