• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
redirecting and alerting after the session has cleared

I have found that if I leave my system sitting at one of its views for more than 7200 seconds (with no interaction) the session variable clears and I lose track of the name and userid of the user. What I'd like to do is popup an alert saying "you have been logged out" and display my Users view which is the login screen.

if (!isset($_SESSION['isUserLoggedIn'])){ //if the session has cleared log the user out


I have also tried $this->load->view('Users/logout'); instead of the redirect but "no go"

The problem is that I am unable to alert and I am also unable to send the user back to the login screen. I have researched and discovered that I need to do this in javascript since PHP doesn't become active until the user interacts with the screen. But, my HTML file, which has some js on it, is not even displaying at this time. Is there any type of event I can get when $config['sess_expiration'] fires?
proof that an old dog can learn new tricks

The alert idea would require some js that polls periodically for the value of $_SESSION['isUserLoggedIn']. Kind of resource intensive though it might be possible to use a webworker to handle the polling.

I'm curious why you are unable to redirect to the login page.

Hey Dave. The redirect works now. I had the URL wrong. Now I have


and it works.

I still wish I could popup a message. Well I guess I am ok for now. Now back to my OrgChart issue!

proof that an old dog can learn new tricks

I am still fooling with the alert. I have this in a file called javascript_funcs.js

   if(typeof timeOutObj != "undefined") {

   timeOutObj = setTimeout(function(){
   window.location = "/";
   alert ("logoff due to inactivity");
}, 6000);   //will expire after 6 secs

I have it set to 6 secs just for testing. What I am finding is that unless a user clicks on item on my menu, the timer is never set. So for example a user logins in and then doesn't do anything, the click event never fires and then the logoff timer never fires.Is there some way to force the set Timer to start when the system first comes up (without a user click)?
proof that an old dog can learn new tricks

I figured it out. I will use $(document).ready(function() to start up the timer.
proof that an old dog can learn new tricks

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.