In my application I want to allow for some user, to be able to sign out all other users except him/her. I have done this functionality, well, when the Session driver was set to file, but now I'm using redis as session driver and I could not able to find any way to list up all current sessions like I have done when it was file driver.
The question is: How to list up all sessions IDs when using redis as a session driver?
The following is the code that I have used when session driver was file:
public function signoutAllUsers(Request $request,$sesId=null){
//dd(session());
if ($sesId == session()->getId()){
$dir = storage_path().'/framework/sessions';
$files = scandir($dir);
foreach ($files as $file){
if ($file == session()->getId() || strpos($file,'.') !== false){
//echo "ggg";
continue;
}
try{
unlink($dir.'/'.$file);
}
catch(\Exception $e){
return $e;
}
}
$request->session()->flash('status','success');
$request->session()->flash('msg',__('All users have been signed out successfully'));
return redirect('/method/create');
}
else{
return redirect('/method/create');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire