Manually Logging a User In


You want to manually log a user in.


Use the Auth::login() method.

This logs the user into the current session, bypassing any authentication.

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

You can also specify true as the second parameter to set the "remember me" cookie.

Auth::login($user, true);


The Auth::attempt() method does this automatically.

In face, if the authentication is successful, Auth::attempt() will call Auth::login() internally.

But, if you need to bypass authentication altogether, this is a great method to use. It's especially useful when testing: just create a temporary route to log a user in using this method.

This will fire the auth.login event.

comments powered by Disqus