Need Advice : logout when timeout


Tinn Aphopchung

Hi, David
I need some advice in mobile app.In website,we can use cookies and session to manage user login.How about on mobile app?What I want to do is when user close app(Not exit app.just close but app still run in background) when they open app again.I need to check session or cookies or something that ticker user to login again if time limit run out.Did we have some example?


DecSoft

Hello tin,

I am not quite sure about what exactly you need. But we must start from some point, then, what about the SetOption and GetOption actions? We can also use the cookies' related actions, but, personally, I save the user's login data into the local storate using the SetOption and GetOption actions. This actions works in all Cordova's platforms and also in the browsers. Please, if you refer to other thing, post here and I will try to help you.



Tinn Aphopchung

I want to let app check the time limit after login.When user close app(App still run in background) and then open again.Normally it will show last view use.What I want is to check time limit that user login.If time limit exceed then go to login view again.
Did setoption can solve this?Look like set option will let the app not going to login again.

I want user re-login when time is go out after re-open app when time is exceed.Like we use session in php.


Ade Wale

I feel like this is a more easy approach. I'm not sure if this is the best way but here goes. What you can do is:

Set a PHP Session ($_SESSION['timeout']) to current time (time()) when the user logged in.
Wrote the following function to validate whether the user is active.

// This function is adding 900 seconds (15 Minutes, which is the amount of time you want the user to // be inactive to automatically logout) to the previously registered time when the user was last active. // Then, its checking whether the current time is greater than the amount of time you want the user to // stay logged in without timing out (which is 15 minutes). If it's greater, then you are redirected to the // login page where you can initiate a logout function with http://www.yourwebpage/login.php?status=timeout on the URL.


DecSoft

Hello to all,

My apologies: I am not very good of health this last week. About your question, tin, do you remember we have app's events like "Pause" and "Resume"? Maybe you can start a Timer in the "Pause" event and then look for some "count" value in the "Resume" event?



DecSoft

Hello to all,

Just for your information tin, maybe the app's IdleStart and IdleEnd events along with the IdleStart action can help you in some way? I think that the "IdleStart" action can represent a possible approach since we can establish a time, say some minutes, in order to fire the "IdleStart" app's event, so we can "logout" the user at that time.



Ade Wale

Hi David,
Hope you are feeling fine now.
Idlestart and End is good idea. What about if the username and password credentials are going to be from external database?


DecSoft

Hello edunt,

Thanks sir, I am not completely fine, but better. About your question, certainly I am not sure if can understand very well. Can you please explain a little more for me?



Ade Wale

Hi David,
Hope you get well soon.

My question is, will idlestart and end work if username (login) details are stored on the database server and want user re-login when time is go out after re-open app when time is exceed.Like we use session in php.


DecSoft

Hello to all,

Hi David,
Hope you get well soon.

My question is, will idlestart and end work if username (login) details are stored on the database server and want user re-login when time is go out after re-open app when time is exceed.Like we use session in php.

I think that depends on your requeriments. For example, you can use the app's IdleStart event in order to perform some HTTP call to your app's server to perform the logout too. And/or the server can also implement certain kind of "automatic logout" mechanism too of course.


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.