title: logout timer php/javascript
body: <p>I have a javascript timer to logout the user after a certain period of innactivity (when there is no mouse movement or clicks on the document).</p>
  
  <pre><code>document.onkeypress = ResetTimer;
  document.onmousemove = ResetTimer;
  wait = 10;
  function ResetTimer()
  {
      time = new moment();
      clearTimeout(timer);
      timer = setTimeout("Logout()", 60000 * wait); //logout the user with an ajax call
  }
  </code></pre>
  
  <p>I also have a session variable which tracks the last time the user has made a php call. If the user hasn't made any request in 10 minutes, the user is logged out. The issue I am having here is that if the user moves on document while staying on the same page, he won't get disconnected by the javascript, but the PHP will on his next request. Would it be a good practice to refresh the session variable with an ajax call after 9 minutes the user is on the same page (since the wait time is 10 minutes)?</p>