PHP Classes

File: js/session.js

Recommend this page to a friend!
  Classes of Mehmet Kidiman   Developbat PHP CRUD   js/session.js   Download  
File: js/session.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Developbat PHP CRUD
Show pages to manage table records using Bootstrap
Author: By
Last change:
Date: 2 years ago
Size: 1,561 bytes
 

Contents

Class file image Download
// session expiration in milisec var sess_pollinterval = 60000; // session valid min var sess_expirationMinutes = 20; // warning time min var sess_warningMinutes = 15; var sess_intervalID; var sess_lastActivty; function initSessionMonitor(){ sess_lastActivty = new Date(); sessSetInterval(); $(document).bind('keypress.session',function(ed,e){sessKeyPressed(ed,e);}); } function sessSetInterval(){ sess_intervalID = setInterval('sessInterval()',sess_pollinterval); } function sessClearInterval(){ clearInterval(sess_intervalID); } function sessKeyPressed(ed,e){ sess_lastActivty = new Date(); } function sessPingServer(){ // call function keep alive //aliveAjaxFunction(); alert("Oturum kontrolü..."); } function sessLogOut(){ window.location.href='logout.php'; } function sessInterval(){ var now = new Date(); var diff = now-sess_lastActivty; var diffMins = (diff/1000/60); if(diffMins >= sess_warningMinutes){ //run before expiring //stop timer sessClearInterval(); //prompt attention if(confirm('Oturumunuz sona erecektir'+(sess_expirationMinutes-sess_warningMinutes)+' süre sonra '(''+now.toTimeString()+ '), Tamam a basarak oturumda kalabilirsiniz'+ 'Kapata basarak oturumu sonland?rabilirsiniz. \nlf oturumunuz kapand?')){ now = new Date(); diff = now-sess_lastActivty; diffMins = (diff/1000/60); if(diffMins > sess_expirationMinutes){ //timed out sessLogOut(); }else{ sessPingServer(); sessSetInterval(); sess_lastActivty = new Date(); } }else{ sessLogOut(); } }else{ sessPingServer(); } }