18
Views
4
Comments
We need guidance regarding tracking a user’s login status within an OutSystems app

Our requirement is very specific and limited in scope:

We need a reliable flag or indicator to determine whether a user is:

  • Currently logged in, or
  • Logged out (for any reason)

We do not need to differentiate between:

  • Manual logout
  • Session timeout
  • Accidental logout

We only need a binary status:

  • Logged In
  • Logged Out

Use Case

This flag will be used to:

  • Check whether a user session is active
  • Update user presence/status correctly
  • Avoid relying solely on session expiration assumptions

Question

Could you please advise:

  1. Is there any built-in OutSystems variable, system entity, or event that can be used to determine whether a user is currently logged in?
  2. If not, what is the recommended best practice to maintain a login/logout flag (e.g., using UserId, session lifecycle events, or custom tracking)?

We want to ensure this is implemented in a supported and reliable way.

Thank you for your guidance.

Best regards,
Ishika Thakkar

2025-12-22 13-50-43
Sherif El-Habibi
Champion

Hello,

I don’t think there is a built-in variable that directly tracks the current login status. What you do have is the Last_Login attribute in the User entity, and in Service Center you can see that a user has logged in, but that’s about it.

This might not be an official or recommended approach, more of a brainstorming idea, and there may be better solutions, but here’s one possible way to handle it.

You can extend the User entity by creating a one-to-one strict relationship where the primary key is the User Id. In this extension entity, you add an attribute like IsLoggedIn. When the user logs in, you create a record in this extension entity and set IsLoggedIn to True. This action can then trigger a process that contains the logic to evaluate the login status and update it.

Alongside this, you can create a Timer that runs, for example, every 15 minutes daily. This Timer calls a Server Action that re-launches the same process to re-check the login status and update it if needed. When the user logs out, you simply update the IsLoggedIn attribute to False.

So the flow would be: User logs in → create a record in the extension entity and set login status to True → trigger a process that checks the login status and updates it accordingly (sets it to False if logged out, or does nothing if still logged in) → the same process is re-triggered by a Timer every 15 minutes → when the user logs out, the status is explicitly updated to False.

When launching the process, you pass the User Id as input, which corresponds to the record in the extension entity.

Of course, you might ask why not just update the record on login and logout and avoid using a process altogether. The reason is that, in your business case, you need an up-to-date and more reliable status. By checking periodically, for example every 15 minutes, you can verify what the user is currently doing. The user might still be in the same session for a long time and hasn’t explicitly logged out, so relying only on login and logout events may not be enough. In the end, this approach really depends on the business scenario and how accurate the login status needs to be. 

2025-02-10 17-24-13
Arun Rajput

Hi Ishika,

As sherif explained we don’t have any boolean flag in user entity. If you want to go with boolean flag than managing user extension entity is best way


2024-10-05 13-30-20
Huy Hoang The

As Sherif mentioned, 

We can trigger a timer to run every 5 minutes to check if the user is logged in, then log it back into the entity. For mobile, I found 2 event On Pause & On Resume (via the Cordova Plugin) to check the user's status. 

Why every 5 mins ? 

- Because I see that's how the Facebook app is implementing it. when i refresh my friends profile, the system will notify me that the user left 5 minutes ago. 

- And If we have the LastLogin field, we can easily calculate the user's offline time.

That's a very interesting question; please let me know if you have any ideas. 

Huy Hoang.


2023-10-16 05-50-48
Shingo Lam

make sense for the interval checkup, because there will be the session timeout that forces the user logout, this logic can be also added to your statements

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.