How to manually log users out of your application in laravel

 By using this method you can simply destroy the current logged in user session . To manually log users out of your application, you may use the logout method on the Auth facade. This will clear the authentication information in the user's session.

This article is also helpful for those developer who logged in but do not have logged out option in their application or any situation in which they want to logged out their current logged in user session. They can simply use this method to logged out from the current user's session. 

For this we have to create a route  and a controller method .

Copy and paste this code to your web.php file under < yourproject/routes/ > folder or may be different as per your laravel version. 

Route::get('/logout-user-session', '[email protected]');

To create LogoutController file you can run php artisan command.

php artisan make:controller LogoutController

Copy and paste this code in your LogoutController file after the namespace and before the class defination.

use Illuminate\Support\Facades\Auth;

After that you have to creat logout method in your LogoutController file. You can simply copy and paste below code in your LogoutController file. 

public function Logout(){

     Auth::logout();
     return redirect('/login');

}

You have to simply hit /logout-user-session  and now you are logged out of your current logged in user session.