title: javascript window unload event
body: <p>I am calculating how many users online, but if a person close a window without logging out, he is not online, I need to make that user logout dynamically through javascript or jquery.
  when i use body <code>onunload</code> event to check this it works but if i refresh the page it also calls the body unload event. </p>
  
  <p>Here is my code</p>
  
  <pre><code>&lt;script&gt;
  function LogmeOut()
  {
    window.location='logout.php';
  }
  &lt;/script
  &lt;body onUnload="LogmeOut();"&gt;
     .....
     .....
  &lt;/body&gt;
  </code></pre>
  
  <p>The logout php will signout the current user before closing the window.
  Any suggestions?</p>