title: How to reset session on keypress
body: <p>I have implemented session timeout using setInterval() when the window loaded. How to reset session time on keypress event. Here is the code that I've written.</p>
  
  <pre>
  
      
           window.onload = function(){
           (function(){
             var counter = 60;
             setInterval(function() {
               counter--;
               if (counter >= 0) {
                  //alert(counter)
                  span = document.getElementById("count");
                  span.innerHTML = counter;
               }    
  
               if (counter === 0) { 
                   $("#session-expired-modal").modal('show');
               } 
             }, 1000);
            })();
          }
          function sessionExpiredRedirect(){
            window.location=url;
          }  
       
  
  </pre>