Laravel - force logout of specific user by user id

后端 未结 3 778
滥情空心
滥情空心 2020-12-29 15:55

I use Laravel 5.2.

I want to know how can I force a user to logout by id?

I\'m building an admin panel with the option to dis-active specific user that are

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 16:25

    Use the setUser to find a soluion

    • get current user

         $user = Auth::user();
      
    • logout user you want to, by id

         $userToLogout = User::find(5);
         Auth::setUser($userToLogout);
         Auth::logout();
      
    • set again current user

         Auth::setUser($user);
      

提交回复
热议问题