title: How to implement auto logout in Javascript
body: <p>The below code works for the most part but I am wondering if it's possible to tweak it a bit. If there is no mouse activity for x number of milliseconds, a popup window is displayed saying that you will be logged out. Then,  if / when you click the ok button the script will automatically bring you to the logout file.</p>
  <p>However, I would also like to bring the screen to the logout.php file if the ok button is not clicked after x number of milliseconds. Does anyone know how I might do this with the below code?
  Thanks</p>
  <pre><code>// Set timeout variables.
  var timoutWarning = 840000; // Display warning in 14 Mins.
  var timoutNow = 100000; // Timeout in 15 mins would be 900000.
  var logoutUrl = 'logout.php'; // URL to logout page.
  
  var warningTimer;
  var timeoutTimer;
  
  // Start timers.
  function StartTimers() {
      warningTimer = setTimeout(&quot;IdleWarning()&quot;, timoutWarning);
      timeoutTimer = setTimeout(&quot;IdleTimeout()&quot;, timoutNow);
  }
  
  // Reset timers.
  function ResetTimers() {
      clearTimeout(warningTimer);
      clearTimeout(timeoutTimer);
      StartTimers();
      $(&quot;#timeout&quot;).dialog('close');
  }
  
  // Show idle timeout warning dialog.
  function IdleWarning() {
  //  $(&quot;#timeout&quot;).dialog({
      //modal: true
      alert(&quot;Warning, your page will redirected to login page. Due to not move your mouse within the page in 15 minutes.&quot;);
  //});
  }
  
  // Logout the user.
  function IdleTimeout() {
      window.location = logoutUrl;
  }
  </code></pre>