Welcome Guest, Not a member yet? Register   Sign In
codeigniter session destroy if user is idle for some time
#1

[eluser]lavi jain[/eluser]
i also want to do the same.

i want that after login if user is idle for sometime for example may be for 5 minutes then he will got a message that

‘he is going to logout. and by clicking can save his session’.

if he click the time will be reset.

if not then after waiting for more 5 minutes user account will be logged out automatically.

but iam not getting any idea to do this..


what i am using is codeigniter to do this and what script iam trying is this:

[removed]
var timer = 0;
//var timesRun = 0;
function set_interval() {

// the interval ‘timer’ is set as soon as the page loads
//timer = setInterval(“session_expired_message()”, 9000);

timer = setInterval(“auto_logout()”, 10000); //uncomment to continue


// the figure ‘10000’ above indicates how many milliseconds the timer be set to.
// Eg: to set it to 5 mins, calculate 5min = 5x60 = 300 sec = 300,000 millisec.
// So set it to 300000
}

function reset_interval() {
//resets the timer. The timer is reset on each of the below events:
// 1. mousemove 2. mouseclick 3. key press 4. scroliing
//first step: clear the existing timer

if (timer != 0) {
clearInterval(timer);
timer = 0;
// second step: implement the timer again
timer = setInterval(“auto_logout()”, 10000); //uncomment to continue
// completed the reset of the timer
}
}

function auto_logout() {

//timesRun += 1;
//if(timesRun === 2){
var con = confirm(“your session will be destroy soon click ok to destroy session or cancle to continue!”);
if(con == true ){
alert(“your session expired”);
[removed].href =”<?php echo site_url(‘user_controller/logout’);?>”;
}
else {
alert(“your session is continue”);
reset_interval();
}

//}



}


[removed]



i am calling this at body

<body >



this is it

i need help regarding that how should i use this code in codeigniter to make it work after user login and also where to write this in which file i should call it . i am not getting an idea to implement this code.

someone please help

thanks




Theme © iAndrew 2016 - Forum software by © MyBB