Introducing

How to logout in Laravel


Logging out of Laravel is easy and there are two ways to do it. The first way is to use the logout method on the Auth facade:

Auth::logout();

This will clear the authentication information from the session and redirect the user to the login page.

The second way to logout is to use the HTTP Basic authentication method. This is useful if you want to logout from an AJAX request:

return Response::make('', 401, array('WWW-Authenticate' => 'Basic realm="Laravel"'));

This will return a 401 Unauthorized response which will cause the browser to popup a login dialog.

That's all there is to it! Logging out of Laravel is simple and straightforward.

Something you may be interested:
Categories:
Tags:
Laravel
Logout