Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

My app is running on iOS and Android and uses the Appery Login Service. I would like for users who log in to stay logged in until they Log Out, or reset their system. But for some reason, my app (especially with iOS) will automatically log out (when not in use), either after a given time period or after use of other apps. I am not sure what causes the log out, or if it triggers a reload of the app which then triggers the need to log back in.

Any thoughts on this?

Is there any specific documentation on the login_service and why this might be happening?

Thank you!

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

Hi Christopher,

You can save sessionToken in a localStorage variable and store it in your app.

Check it when run the application, and invoke login service if it's expired, or use the current one.

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

Right now I save the sessionToken to a local storage variable called session_id.

Can you provide more details on how to check it and the invoke the login service if it's expired?

The big question is: When the login service is invoked after detecting that the sessionToken has expired does the user have to login again???

What makes the token expire???

Thank you!

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

Hi Christopher,

Login processing you have to implement could be written by next steps:

  1. session_id - is empty

  2. Login service invoked and as result - session_id is filled.

  3. Event "session expired" - is triggered.

  4. logoutService invoked

  5. session_id - is cleared and user interface redirects to non-loged page(for example - login page).

    So you have 1 and 2 actions working.

  6. create javascript file with next content:

    pre
    function LogoutOnExpire(){
    var timerToLogout = localStorage.getItem("timerToLogout");

    if(timerToLogout)
    clearTimeout(timerToLogout);

    var logOut = function(){
    console.log("logout");
    };
    var timerToLogout = setTimeout(logOut, 100000);
    localStorage.setItem("timerToLogout", timerToLogout);
    };

    function LogOut(){
    logout_service.execute();
    };/pre

    Where "logout_service" - is name of your service on data tab on page.

  7. Call LogoutOnExpire function on every user action. (For example, for Screen on Tap event Run JS with code:

    preLogoutOnExpire();/pre)

  8. On success event for Logout service set to "" session_id localStorage variable and go to the login page.

    [quote:]The big question is: When the login service is invoked after detecting that the sessionToken has expired does the user have to login again???[/quote]

    Yes, if session_id is expired, user have to login again.

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

Can you please confirm that this code will maintain the user's state as logged in UNTIL they select to be logged off by clicking the Log Off button.

I want the user to remain logged in until THEY decide to logout.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

Dear Christopher,

Not quite, this code allows you to make autoLogout. So if you set delay to user idle as 60000 - and user does not make any actions with application - this code is automaticaly making logout.

But it could be easly modified:
You can change delay in this line of code

prevar timerToLogout = setTimeout(logOut, 100000);/pre

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

What I actually want to do is to make sure that the user is not auto-logged out.

Is there any way to do that?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Appery Login_Service Details: When/Why Does it Auto-Log Out Users?

Hello! If you don't use token for a while (2 hours), then session token is expired automatically and there is no much you can do... You can save login and password into localStorage and check if token is expired (please take a look here https://getsatisfaction.com/apperyio/...). If it's expired, make login invisible for user and this way update session token.

Return to “Issues”