How to Auth Logout in Laravel 5

0

In this tutorial, we are going to cover the authentication logout system in the Laravel 5 framework. Auth::logout() function to destroy all authentication information so find out below code. You may also like How to Create Authentication Login in Laravel 5 and Shopping Cart using Laravel 5.

Steps For How to Auth Logout in Laravel 5

Step 1. Create route

We are required only one route to call controller.

Route::get('logout', [
    'as'    => 'logout',
    'uses'  => 'SigninController@Logoutuser'
]);

Step 2. SigninController with Logoutuser function

We will first need to import the Auth namespace.

use Illuminate\Support\Facades\Auth;

In this step authentication destroy.

public function Logoutuser()
{
    Auth::logout();
    return redirect('login');
}

And if you like this tutorials please share it with your friends via Email or Social Media.