Advertisement
fahmihilmansyah

Auto Logout JS

Oct 2nd, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. idleTime = 0;
  3. $(document).ready(function () {
  4.     //Increment the idle time counter every minute.
  5.     var idleInterval = setInterval(timerIncrement, 60000); // 1 minute
  6.  
  7.     //Zero the idle timer on mouse movement.
  8.     $(this).mousemove(function (e) {
  9.         idleTime = 0;
  10.     });
  11.     $(this).keypress(function (e) {
  12.         idleTime = 0;
  13.     });
  14. });
  15.  
  16. function timerIncrement() {
  17.     idleTime = idleTime + 1;
  18.     if (idleTime > 15) { // 15 minutes
  19.         window.location.href= "<?php echo this()->base;?>index.php/webadmin/user/logout";
  20.     }
  21. }
  22. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement