I am having problem in which I want to logout user if there is no activity within 180 seconds if there is any then it will reset the timer but the problem is the timer is not resetting I checked through logs here my code
if ($isManager || $isAdmin) { ?> var total_session_time = 180; // In seconds. After this interval of time if user is ideal then clock timer will start in seconds //var total_session_time = 50000;//180; // In seconds. After this interval of time if user is ideal then clock timer will start in seconds var clock_time_start = total_session_time + 1; var idleTime = 0; $(document).ready(function() { // alert('hello'); // console.log('total_session_time->' + total_session_time) //idleTime = $('#idleTime').val(); var sms_access_page = $('#sms_page_access').val(); // get val. for handle the logic of sms page will not logout. // console.log('sms_accss_if_value - '+sms_access_page); var idleInterval = setInterval(function() { if ($('#idleTime').val()) { idleTime = $('#idleTime').val(); } else { idleTime = 0; } if ($('#pauseLogoutScript').val() == 0) { idleTime = parseInt(idleTime) + 5; // as interval is of 5 seconds added 5. } //console.log('idleTime ->'+idleTime); $('#idleTime').val(idleTime); if (idleTime > total_session_time) { count = clock_time_start - idleTime; // console.log('count ->' + count); if (count <= 0) { if (sms_access_page != '' && sms_access_page == '7') { console.log('sms page will not logout- ' + sms_access_page); } else { console.log('logging out'); window.location = 'index.php?r=site/logout' //return; } } } }, 5000); // 1000 = 1 sec $(this).mousemove(function(e) { $('#idleTime').val(''); }); $(this).keypress(function(e) { $('#idleTime').val(''); }); }); <?php } ?>
Thank You in advance!
I want to reset the idleTime variable