Logout user from mobile app when session times out

Logout user from mobile app when session times out

  

Hi,

We have a mobile app that requires user to login. When app is not used for a while and session is timed out, the app still works until there is a call back to server. What we need is that app  immediately show login after session timeout and should not rely on a call back to show login.

Is there a trick for that or Cordova plugin? Or only way is to track user activity via local entity attribute and compare for example "last active time" with current one on client side action?


Thanks for any suggestion.


Mykola (Nick) Tkachenko wrote:

Hi,

We have a mobile app that requires user to login. When app is not used for a while and session is timed out, the app still works until there is a call back to server. What we need is that app  immediately show login after session timeout and should not rely on a call back to show login.

Is there a trick for that or Cordova plugin? Or only way is to track user activity via local entity attribute and compare for example "last active time" with current one on client side action?


Thanks for any suggestion.


maybe you could use timer or javascript setTimeout to call user login status every few minutes ? and when status user already session timeout, you trigger redirect to login


It should work even when app is in offline mode.

Mykola (Nick) Tkachenko wrote:

It should work even when app is in offline mode.

then use javascript.

something like this


The question is how to track for user activity. It is not a solution to manually track all scrolls/clicks etc. and set "isActive" variable for example.

Mykola (Nick) Tkachenko wrote:

The question is how to track for user activity. It is not a solution to manually track all scrolls/clicks etc. and set "isActive" variable for example.

its not manual, its automatic because it will run like timer, but using javascript.


and it will run even if user is not touching the screen.

What metrics are you suggest to check in this JS script?

Mykola (Nick) Tkachenko wrote:

and it will run even if user is not touching the screen.

What metrics are you suggest to check in this JS script?

put this on commom/layout, and this script will run on every screen

the thing that must be done is the user checker


Problem is not running script with timer on every screen as async background process but how to detect if application is actively used by user or is just open on the screen. And if user is not interacting with app for certain time logout him.

Mykola (Nick) Tkachenko wrote:

Problem is not running script with timer on every screen as async background process but how to detect if application is actively used by user or is just open on the screen. And if user is not interacting with app for certain time logout him.


maybe you could check, every few minutes check if there any activity (for every activity you change the flag to true), after few minutes check if the flag true or false, if true, change the value to false then continue. if the flag is false when the check trigger, then do redirect to login. the amount of time id the amount of timeout that you expect

that is manual tracking of all clicks, scrolls etc...