Just a few steps… this will logout a user and return them to the login screen if they are inactive for more than 10 minutes (and they try and do something)…
- Set up a couple of global vars in your security module’s “login” app (in onApplicationInit event) - mine is “sec_Login” - yours may be the same or “app_Login” or whatever:
// Define session idle time in minutes
[idle_time] = 10;
[last_active_time] = time();
[idle_time] is up to you - but this is where you define the timeout period in minutes
- Then put this code in a library.
<?php
function check_idle_time($idle_interval) {
// Function to query the current time and compare it against the last active time.
// If the time is greater than the passed idle time (minutes) then log out, forcing a
// re-login - if not exceeded "reset" the last active time to now....
$time_diff = (time() - [last_active_time]) / 60; // Idle time in minutes
if ($time_diff > $idle_interval) {
// Idle time exceeded limit, then logout
sc_redir(sec_Login, "", "_parent"); // Replace 'sec_Login' with your login app's name if different
} else {
// Still within idle time limit - reset start time
[last_active_time] = time();
}
}
?>
Then in every app’s onLoad event (or equivalent event when onLoad not a valid event) call:
check_idle_time([idle_time]);
Make sure also that in every app that you make this call that under Programming -> Libraries you tick your newly added library