Reputation: 13699
Im trying to implement , user login history and allow user to logout from specific device
Im using SESSION_DRIVER=database
and have sessions
table in database
as per laravel documentation
i have user_logins
table with below structure :
session_id |user_id | ip_address | user_agent | browser_name | location | login_at | is_active
Im success fully able to store above information in table user_logins
using UserEventSubscriber handleUserLogin
function
now i want to logout a user from a specific device , how to do it ?
I m able to delete entry from user_logins
table with ip_address
and user_agent
but I also want to logout that user from specific device.
anyone please help me to solve this .
Upvotes: 2
Views: 2996
Reputation: 95
public function authLogoutForOccGolf(Request $request) {
$request->session()->flush();
return redirect('/');
}
Upvotes: 0
Reputation: 1156
put this method in your controller and set suitable route to execute
public function removeSession($id){
\Session::getHandler()->destroy($id);
return redirect()->back();
}
Upvotes: 2