Welcome Guest, Not a member yet? Register   Sign In
session timeout
#1

[eluser]Unknown[/eluser]
Hi all, im looking for a way to capture session expired from javascript. I can easily write a timer to periodically check if the session is still active, but I dont want my timer script to actually update the session timeout. I guess I could not autoload the session library, and instead manually load it on every page I use instead of the 'check' page, but thats such a hassle.

The goal is to redirect users to the login page if their session is expired instead of them only finding out after they try to do something.

Anyone have any tips?
#2

[eluser]Clifford James[/eluser]
Lets say your session timeout is 20 minutes (standard settings) you can have the following javascript on every page:

Code:
setTimeout('window[dot]location = "<?=site_url()?>"', ((1000 * 60 * 20) + 1000)); // 20 minutes and 1 second to be sure session has expired
#3

[eluser]Clifford James[/eluser]
Or you can use

Code:
setTimeout('window[dot]location = "<?=site_url()?>"', ((1000 * 60 * <?=$this->config->item('sess_expiration')?>) + 1000));
#4

[eluser]Unknown[/eluser]
It's not quite so easy. Large parts of the site uses ajax, so i suppose I also have to make sure ajax calls refresh the timer.
#5

[eluser]Clifford James[/eluser]
Yes with:

Code:
window[dot]clearTimeout();




Theme © iAndrew 2016 - Forum software by © MyBB