HOW TO AUTO-LOGOUT AFTER 10 MIN IDLE TIME {HELP}

Hi guys,

I want to auto-logout after 10min idle time, and goto login page.
would anybody can suggest me how can I do that in SC
thanks in advance…
Ahmer

Re: HOW TO AUTO-LOGOUT AFTER 10 MIN IDLE TIME {HELP}

I dont remenber now the function, but in php there’s a function for it.

Re: HOW TO AUTO-LOGOUT AFTER 10 MIN IDLE TIME {HELP}

You need something with a timer. I have been playing with having an app inside one of the widgets on the container type of app. You can set a refresh time in seconds on those widgets. Have it set for like 10 minutes - if it refreshes sooner than that - in the case of a human clicking something that changes and therefor reloads the page, then ignore. If the timer refreshes and the last timecheck was greater than your threshold, then do the logout by calling the app_Login.
Hope that gives some ideas.
Peace,
Jamie

Re: HOW TO AUTO-LOGOUT AFTER 10 MIN IDLE TIME {HELP}

Dear Ahmer,

this is not a counter with auto-logout after 10 minutes (that would require javascript), but it will redirect the user to the login page (or another form that you like) after the session.gc_maxlifetime is expired AND the session is succesfully purged from the server. (read about how PHP will handle the session garbage for more infornation).

the session.gc_maxlifetime is in the php.ini setting that you must set.

So, if you set this PHP setting and use it as timeout, it will redirect the user when the session will expire.

I put this in the onScriptInit event.

if(!isset($_SESSION[‘sm_global_login’])) {
sc_redir(all_loginForm, ‘_parent’);
}

It will chech if the variable will exist and, if not, it redirect to the choosen form (in my case, the form is called all_loginForm)

Note that sm_global_login is a global variable that must be set. I use the login itself as parameter and I made it global after a succesful logon.

I hope that this can help you.

Best regards,
Giuseppe Giardina.

Hi ahmershuja,
You can use this script to Auto-Logout after 10 minutes of idle time in ScriptCase. (Including keyword and mouse movements). Follow these steps:

[SIZE=4]Auto-Logout Example (JavaScript)[/SIZE]
Change idleMax variable if you want more or less minutes of IDLE time. And replace ‘…/LOGIN_APP/’ with your login application URL.

echo '
<script type="text/javascript">
idleMax = 10;// Logout after 10 minutes of IDLE
idleTime = 0;
$(document).ready(function () {
    var idleInterval = setInterval("timerIncrement()", 60000); 
    $(this).mousemove(function (e) {idleTime = 0;});
    $(this).keypress(function (e) {idleTime = 0;});
})
function timerIncrement() {
    idleTime = idleTime + 1;
    if (idleTime > idleMax) { 
        window.location="../LOGIN_APP/";
    }
}
</script>';


Note: Use this code inside a menu that always shows, or insert on the header of all your project applications. This code must be on all your pages.

1 Like

please guys i have a login app and a menu app where do i put this java script

Perhaps a more pragmatic approach? After log-in set a global access time. In every onload you call a php function to determine delta time (currenttime minus access time). If it exceeds your threshold then logout, otherwise set the globalaccesstime to the current time. If you create small procedure (php method or in the repository) you just need to call ‘checktimeout’ or whatever. It will not terminate a session on the screen, but as soon as something is changing due to a user action the accesstime is checked and logged out if necessary.

excellent idea to