J. Doe J. Doe - 6 months ago 12
jQuery Question

Show Logout Modal after 1800 seconds

I have installed a PHP script which logs the user out when 1800 seconds without activity have passed. So when you click a link when 1800 seconds have passed, you will be logged out.

I want this to be real time. So if 1800 seconds have passed, show the user a bootstrap modal. This needs jQuery and that is not a problem at all.

Example;

if(timehaspassed -> 1800 sec) {
show();
}


thanks in advance.

Answer

use setTimeout function of javascript. This will gives alert after 1 second. you can change the time whatever you want.

setTimeout(function(){
  alert("show logout model"); // call your function show(); here
}, 1000);

Reference : http://www.w3schools.com/jsref/met_win_settimeout.asp

Comments