title: Auto-logout using ajax or when browser is exited PHP
body: <p>Using ajax, I made it possible so that a user gets logout after 10 seconds of staying on the same page. Keep in mind that the 10 seconds is just for testing purposes. However, if the user closes their browser before the 10 seconds are up, they do not get log out. I thought about logging them out when they exit their browser, but I have yet to figure out how, and even if I do, what does exiting their browser entails? Does it count if they just close a tab while there are other tabs open? What if they have 2,3 or more browsers open at the same time? How do I determine that all those open browsers are exited before logging them out?</p>
  
  <blockquote>
    <p>test1.php    </p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  include('ajax.php');
  sleep(10);
  
  ?&gt;
  
  &lt;html&gt;
  &lt;body onload = "ajax('test2.php','output',10000)"&gt;
  &lt;div id="output" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <blockquote>
    <p>test2.php</p>
  </blockquote>
  
  <pre><code>&lt;?php
  
  include('connect.php');
  include('functions.php');
  
  ud("login = 'false'/userLogin/where username = '$username'");
  
  ?&gt;
  </code></pre>