Welcome Guest, Not a member yet? Register   Sign In
ajax check session expiration
#2

I haven't used in CI3 session stuff, but I do all this in the browser with JS.  If you're just after a timeout sort of thing, you could do something like this using a tiny JS library (https://github.com/shawnmclean/Idle.js):

Code:
   var paths = window.location.pathname.split( '/' );
   var segment = paths[2];
   // this is because the owners only want people to be logged out if they are at these controllers
   if (segment == 'jobs' || segment == 'home') {
       var awayCallback = function() {
           // this is where we log them out and capture WHY (parameter = idle so we can logout and do a flash msg telling them why they were logged out)
           location.href = '/app/auth/logout/idle';
           // alert("away");
       };
       var awayBackCallback = function() {
           setMessage("back");
       };
       var hiddenCallback = function() {
           setMessage("User is not looking at page");
       };
       var visibleCallback = function(){
           setMessage("User started looking at page again")
       };
       var idle = new Idle({
           onHidden : hiddenCallback,
           onVisible : visibleCallback,
           onAway : awayCallback,
           onAwayBack : awayBackCallback,
           awayTimeout : 900000 // 15 minutes
       }).start();
   }

HTH.  Michael
Reply


Messages In This Thread
ajax check session expiration - by djsuperfive - 04-01-2015, 02:15 PM
RE: ajax check session expiration - by laynebay - 04-01-2015, 07:41 PM
RE: ajax check session expiration - by casa - 04-06-2015, 11:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB