How is your experience with the OutSystems Community?
12
Views
1
Comments
Implementing Fast and Secure Persistent Login Using Local Storage in OutSystems Mobil
Application Type
Mobile

Hi everyone,

I’m developing a mobile application in OutSystems and would like to implement persistent login.

My requirement is that users should log in only once. When they close and reopen the application, they should be automatically authenticated and redirected to the Home screen, without entering their credentials again.

I’m considering using Local Storage for this purpose. I also want to ensure that the authentication check is secure and performs quickly, without causing a noticeable delay during app startup.

What would be the recommended and most efficient approach to implement this in OutSystems Mobile?

Thanks in advance for your guidance.

2023-12-26 10-35-28
OutSystems Neo
Staff
AI Generated

You don’t need to implement your own “remember me” with Local Storage. OutSystems mobile (and Reactive) already supports persistent login natively, and that’s both the recommended and the most efficient approach.

1. Use the built‑in persistent login

In your login logic, call the system action User_Login with:

  • Username / Password: user credentials
  • RememberLogin = True

When RememberLogin is True, OutSystems issues persistent authentication cookies/tokens so that, after the first login, the user doesn’t need to re‑enter credentials unless:

  • The user logs out (via User_Logout), or
  • The persistent login expires (idle time or max lifetime).

This is the official “remember me” mechanism for Mobile and Reactive apps. Persistent Login

2. Configure how long “login once” lasts

Environment-wide settings are configured in Service Center:

  • Cache Time (minutes) – validity of cached auth info before issuing new tokens.
  • Persistent authentication:
    • Max Idle Time (days) – maximum days without activity before forcing re-login.
    • Cookie Expiration (days) – absolute maximum duration of the persistent login.

For mobile apps, these settings control how long “log in once” actually means in practice. Set security for an environment

3. Startup flow (no noticeable delay)

On your initial “splash” or “launch” screen:

  1. Call CheckSession() (or simply rely on GetUserId() / Session.UserId) from a server/logic flow to see if the user is authenticated.
  2. If authenticated → redirect immediately to Home.
  3. If not → redirect to Login.

Because the platform manages cookies/tokens under the hood and they’re checked on the first server call, you don’t need extra Local Storage checks. The server-side authentication lookup is already optimized and typically very fast.

4. Avoid storing credentials in Local Storage

Do not store the username/password locally (even encrypted):

If you need to remember some user context locally (e.g., last logged-in username, preferences), use Client Variables / Local Storage for non-sensitive data only.

5. Optional: extra security

Depending on your use case:


Summary:
Use User_Login with RememberLogin=True + configure persistent authentication in Service Center, and on app startup just check if the session is authenticated and redirect accordingly. This gives you secure, fast, and native persistent login without managing Local Storage yourself.

This answer was AI-generated. Please read it carefully and use the forums for clarifications
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.