title: After session destroy or close browser tab or close browser execute logout using Laravel 5.2
body: <p>In my project I am using session destroy method which very simple way in Laravel 5.2 . </p>
  
  <pre><code>/*
      |--------------------------------------------------------------------------
      | Session Lifetime
      |--------------------------------------------------------------------------
      |
      | Here you may specify the number of minutes that you wish the session
      | to be allowed to remain idle before it expires. If you want them
      | to immediately expire on the browser closing, set that option.
      |
      */
  
      'lifetime' =&gt; 10,
      'expire_on_close' =&gt; true,
  </code></pre>
  
  <p>Now my question is when session destroy automatically or user close browser tab or close browser that time execute logout query. Is it possible execute logout function all cases?</p>
  
  <p>My logout function</p>
  
  <pre><code>public function logout() 
  {
      $user = Auth::user()-&gt;toArray();
      $user1 = ActiveUsers::where("assinedto_id",'=',$user['_id']);        
      $user1 -&gt;delete();
      Auth::logout();
      return redirect('/login');
  }
  </code></pre>
  
  <p>I want to when session destroy or close browser tab or close browser that time run <strong><code>logout()</code></strong>  function. Please suggest me. Thanks</p>