title: Laravel session timeout warning with socket.io
body: <p>I am trying to create a lock screen for user after 20 minutes ( for testing I put 20 seconds).</p>
  
  <p>I created a middleware, which redirects to locked screen where user can insert the password to unlock it again. This works fine on reload, but I would like to do it with socket.io so the user will get a warning let's say 5 minutes before the account goes to locked status and that's where I am struggling.</p>
  
  <p>This is my middleware</p>
  
  <pre><code>    /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request $request
       * @param  \Closure $next
       * @return mixed
       */
      public function handle($request, Closure $next)
      {
  
          if (!$this-&gt;session-&gt;has('lastActivityTime')) {
              $this-&gt;session-&gt;put('lastActivityTime', time());
          } else if (time() - $this-&gt;session-&gt;get('lastActivityTime') &gt; $this-&gt;getTimeOut()) {
              broadcast(new SessionTimeoutCheck('hello'));
              $this-&gt;session-&gt;forget('lastActivityTime');
              $this-&gt;session-&gt;put('locked', true);
  
              return redirect($this-&gt;getRedirectUrl())-&gt;with([$this-&gt;getSessionLabel() =&gt; 'You have been inactive.']);
  
          }
          $this-&gt;session-&gt;put('lastActivityTime', time());
  
          return $next($request);
      }
  </code></pre>
  
  <p>This works fine with reload.</p>
  
  <p>I have this on my client JS </p>
  
  <pre><code>    /**
   * @desc Session timeout warning and lock screen
   */
  socket.emit('private.user.channel', {
      channel: 'private.user.channel.' + user_id,
  }).on("App\\Events\\API\\SessionTimeoutCheck", function (data) {
      console.log(data);
  });
  </code></pre>
  
  <p>So now I am wondering if I should create a command, that runs every minute to check if specific time has passed and then show the warning or what would be the best approach?</p>