Our requirement is very specific and limited in scope:
We need a reliable flag or indicator to determine whether a user is:
We do not need to differentiate between:
We only need a binary status:
Use Case
This flag will be used to:
Question
Could you please advise:
We want to ensure this is implemented in a supported and reliable way.
Thank you for your guidance.
Best regards,Ishika Thakkar
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.
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
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.
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