#1 2017-08-31 08:06:18

tin
Member
Registered: 2016-03-20
Posts: 161

Need Advice : logout when timeout

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?

Offline

#2 2017-08-31 08:47:59

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: Need Advice : logout when timeout

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.

Online

#3 2017-08-31 16:46:04

tin
Member
Registered: 2016-03-20
Posts: 161

Re: Need Advice : logout when timeout

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.

Offline

#4 2017-09-01 06:31:25

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Need Advice : logout when timeout

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.

    function sessionTimeOut() {

// 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.

    if ($_SESSION['timeout'] + 900 > time()) {

      // User Active so reset time session.
      $_SESSION['timeout'] = time();

    } else {

      // session timed out then redirect to login page
      header('Location:http://'. $_SERVER[HTTP_HOST] . '/login.php?status=timeout');

    }

    }

Offline

#5 2017-09-01 20:53:37

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: Need Advice : logout when timeout

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?

Online

#6 2017-09-05 08:18:27

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: Need Advice : logout when timeout

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.

Online

#7 2017-09-07 18:22:33

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Need Advice : logout when timeout

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?

Offline

#8 2017-09-07 18:24:45

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: Need Advice : logout when timeout

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?

Online

#9 2017-09-07 19:08:47

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Need Advice : logout when timeout

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.

Offline

#10 2017-09-07 21:46:35

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: Need Advice : logout when timeout

Hello to all,

edunt wrote:

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.

Online

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.