How to invalidate a user sessions and cookies with user_id in laravel?

Advertisements

In my project admin need to invalidate user auth, and redirect user to login page after receiving the next request from user.

For this operation, anything that authenticates the user must obsolete!
but how ?

Something like the following method :

use App\Http\Controllers\Auth\authController;

...
    authController::invalidateAuth($user_id);
...

>Solution :

logout user you want to, by id:

$userToLogout = User::find(5);
Auth::setUser($userToLogout);
Auth::logout();

Leave a ReplyCancel reply