How to Logout from all other devices Laravel 10 | Single Session Login in Laravel

Amit Kumar
Oct 17, 2024

--

In this tutorial we’re going to learn how to logout another device if login another browser then logout from another device.

First step go to Kernal.php and put below code.

\Illuminate\Session\Middleware\AuthenticateSession::class,

Next go to Logincontroller and put the below function.

C:\xampp\htdocs\learning\testing\app\Http\Controllers\Auth\LoginController.php
 public function authenticated(Request $request){
Auth::logoutOtherDevices((request('password')));
}

Import this class as well

use Illuminate\Http\Request;

Next to run your project using below command.

php artisan serve

Now if you same id login with two browser then refresh 1 browser 1 automatic logout from another devices.

--

--

Amit Kumar
Amit Kumar

Written by Amit Kumar

Hi I am Amit Experienced Web Developer with a demonstrated history of working in the information technology and services industry.

No responses yet