PHP Laravel : How to logout from other device with same userId forcefully -


i'm building laravel application user logged in other device , while logged out want force him logged out other device also. how implement in laravel.

personally have used redis server that.but don't know why it's not working. while running program have run redis-server.exe also.and i'm in windows. , here controller have written login forcing user logged out other device. if find solution please me find out.thanks in advance.

controller:

  public function postsignin(request $request)   {            if (auth::attempt(['email' => $request['email'], 'password' =>$request['password'] ]) ) {         $redis = \redis::connection();          $userid = auth::user()->id;       $redis->sadd('users:sessions:' . $userid,session::getid());             return redirect()->route('main');     }     return redirect()->back(); }    public function getlogout() {     $redis = redis::connection();     $userid =auth::user()->id;     $usersessions = $redis->smembers('user:sessions:' . $userid);     $redis->sadd('users:sessions:'.$userid,session::getid());     $currentsession = session::getid();     foreach ($usersessions $sessionid) {       if ($currentsession == $sessionid) {         continue;        }       $redis->srem('user:sessions:' . $userid, $sessionid);       $redis->del('laravel:' . $sessionid);     }     auth::logout();     return redirect()->route('main'); } 

when loop each user session load it's id , clear data in it:

    foreach ($usersessions $sessionid) {         if ($currentsession == $sessionid) {             continue;         }         $redis->srem('user:sessions:' . $userid, $sessionid);         $redis->del('laravel:' . $sessionid);         \session::setid( $sessionid ); //add         \session::clear(); //add     } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -