Search code examples
androidibm-mobilefirstworklight-security

How to mantain the LTPA Token after closing the application?


I have implemented WASLTPAAuthentication (with WASLTPALoginModule and Realm) and it works well.
I can call my JAX-RS and they took the identity by the cookie.

My problem is: after I tap the Home button and open the menu of recent applications to swipe and quit the application, then once I open it again the session is destroyed and the cookie is lost and I need to insert my credentials and login again.

Is there a way to prevent this? Do I need to store the cookie on the localStorage in some way?


Solution

  • It looks like even though your LTPA cookie is still valid, when you close the application and the session dies, the cookies are being cleared. You will need to save the LTPA cookie in local storage and then set the cookie manually if you want it to use it for multiple sessions.

    The LTPA cookie is included in the attributes object of the UserIdentity returned after successfully logging into the WASLTPARealm, so you should already have access to it. Its just a matter of saving and retrieving it.