JillElaine / jquery-idleTimeout

Idle activity timeout and logout redirect for jQuery for multiple windows & tabs
Other
73 stars 79 forks source link

Session Timeout starts count down after unlocking the screen on a mobile device #27

Open b-barman opened 8 years ago

b-barman commented 8 years ago

Example Configuration - session time out at 10 mins, count down timer to display set at 60 seconds.

Problem Scenario - User is on a mobile device such as ipad and then leaves for some time say by locking the screen or the screen times out. Once the user comes back, if the session has already timed out and when ideally the user should have been taken to the logout screen, the modal window still shows up with the count down timer message and keeps showing it for about 5-10 seconds before taking the user to the logout screen. This gives false impression to the user that he can extend the session and also is not an ideal UX.

JillElaine commented 8 years ago

Is the client's browser in a suspended state when the screen is locked?

b-barman commented 8 years ago

Not sure if by suspended you meant if the browser was minimized or in the background but in my case, the browser was in the foreground, although I would like to know also how it would behave if it was in the back ground.

JillElaine commented 8 years ago

Because mobile devices use a battery, apps may be suspended when not in use to save battery power. Not sure how to continue to have an idletimer check for idleness or redirect to a log out page when the browser is suspended.

http://stackoverflow.com/questions/6543325/what-happens-to-javascript-execution-settimeout-etc-when-iphone-android-goes

http://www.makeuseof.com/answers/apps-webpages-always-reload-multi-tasking-ipad-2/

b-barman commented 8 years ago

So would it be fair to say that for mobile browsers we need another mechanism may be cookies or something similar to track the suspended state?

JillElaine commented 8 years ago

Apparently there are methods to determine if a mobile browser has returned from or is about to go into a suspended state. Which method to use depends on the iOS of the device, I think?

Here is one method that may work for some devices: http://docs.phonegap.com/en/4.0.0/cordova_events_events.md.html

document.addEventListener("resume", onResume, false);

function onResume() {
    // Handle the resume event
    logoutUser();
}

Perhaps you could test this? I do not have a mobile device of any kind, sorry.