title: How to check idle time using jQuery and PHP?
body: <p>I have a script that uses PHP <code>SESSION</code>. I manage PHP sessions using a class. Within this class I have a method that returns how many seconds remaining before the session expires.</p>
  
  <p>Also, Evey time the user refresh the page or open a new page (new request to the server) the idle time counter starts over <code>$_SESSION['MA_IDLE_TIMEOUT'] = time()+900;</code></p>
  
  <p>What I am looking to do is display a dialog message 2 minutes before the PHP session expire and check if the user is still on the page or not. If the use clicks "Keep working" then the jQuery script will send PHP AJAX request to renew the session  <code>$_SESSION['MA_IDLE_TIMEOUT'] = time()+900;</code>. If the user did not click anything or clicked on "Log out" then the session ends and the user is redirected to the login page.</p>
  
  <p>I did find a nice plugin that will somewhat does the Job <a href="https://github.com/ehynds/jquery-idle-timeout" rel="nofollow">jquery-idle-timeout</a></p>
  
  <p>The issue with this plugin is that it checks if the user is idle using JavaScript (if the keyboard/mouse) are being used. Here is the senario where this script does not help me: lets say my PHP sessions has a limit on 15 minutes/ 900 seconds. A user is reading a super long article on the same page. He/she will be scrolling, they are not really idle "from JavaScript perspective" but from a PHP perspective the use is idle. Then after 20 minutes the user refresh the page, then the user will be logged out since he/she have not sent a new request to the PHP server for over the 900 seconds limit. </p>
  
  <p>How can I solve this problem? is there a better plugin to does the trick? if there something I missed in this plugin that will solve my problem?</p>
  
  <p>Thanks</p>