I\'m trying to implement a user policy whereby only one user can login at a time. I\'m trying to build this on top of Laravel\'s Auth driver.
I\'ve thought of using
Here’s how you can accomplish this. First of all, you need to uncomment the line \Illuminate\Session\Middleware\AuthenticateSession::class from $middlewareGroups property in app/Http/Kernel.php file because this is the middleware that manages the user sessions in Laravel.
2- add this line in your login function just after login attempt successfully and before redirection: \Auth::logoutOtherDevices(request('password'));
use Illuminate\Support\Facades\Auth;
Auth::logoutOtherDevices($password);
if(Auth::guard('student')->attempt([],$request->rememberme))
{
Auth::guard('student')->logoutOtherDevices(request('password'));
return redirect()->intended('/'); //route('homepage');
}
https://www.amitmerchant.com/logout-from-everywhere-except-current-device-laravel/
demo https://xpredo.com