To get the sessions of a certain user by knowing their user_id, you can use the all() method of the Illuminate\Session\Store class. Here's an example:
$user_id = 1; // replace with the actual user_id
$sessions = app('session')->driver()->all();
foreach ($sessions as $session_id => $session_data) {
if (isset($session_data['_token']) && $session_data['user_id'] == $user_id) {
// do something with the session data
}
}
In this example, we're using the app() helper function to get an instance of the session driver, and then calling the all() method to get all the sessions. We're then looping through each session and checking if it has a _token key (which indicates that it's a valid session), and if the user_id key matches the user_id we're looking for. If it does, we can do something with the session data (e.g. delete it, update it, etc.).