Setting the Currently Authenticated User

Problem

You want to set the user for the current request.

Solution

Use the Auth::setUser() method.

$user = User::find($user_id);
Auth::setUser($user);

Discussion

This method does not log the user in.

It simply sets the user for the current request without any sort of authentication.

comments powered by Disqus