See who's logged in?

Is there a way to see which users are currently logged in and using my app?

Here’s a simple method I was just playing around with… it seems to work great, but I’ve only tested it with a handful of online Users, so I’m not sure how it would scale (lots of backend workflows being scheduled and cancelled, so it might use a lot of server capacity with a high volume of users - would need to test it with lots of online users to see how efficient, or not, it is)…

Have a field on the User datatype called ‘Online’ of type yes/no

Set up a backend workflow called “Set User Offline” with a parameter for User, and a single action that sets the User’s Online field to ‘No’

On the page you can continually set the Current User’s Online value to yes (every 3, 5, or 10 seconds for example), whilst also scheduling the ‘Set User Offline’ backend workflow to set it to ‘no’, storing the workflow ID (in a field on the User datatype called ‘Online Workflow ID’), and cancelling the previous scheduled workflow.

So the on-page (every x seconds) workflow could have 3 steps

  1. cancel a scheduled workflow (ID=the current user’s online workflow ID)
  2. Schedule a backend workflow (“Set User Offline”, User = Current User, date=current date/time +15 seconds (longer than the frequency of the on-page every x seconds workflow)
  3. Make changes to Current User: Online = Yes, Online Workflow ID = Result of Step 2

That will keep the User’s Online field set to yes whilst they’re on the page, whilst scheduling a backend workflow to set it to ‘no’, but continually cancelling and rescheduling that workflow whilst they remain online. Only when they leave your app will the backend workflow eventually run to set their online status to ‘no’.

Then, to see who’s online (for example) you can have a repeating group of Users with an Icon inside the cell with a conditional to change, say the icon colour to green, when the current cell’s user’s Online = Yes

As I say, that works pretty well - but I’ve only tried it with a small number of online Users.

I’m not sure how well that would scale - you’d just need to keep an eye on your server logs. If it’s an issue you could always run the workflows less frequently (i.e. every 30 seconds , or every minute etc.) if it becomes a problem at scale.

EDIT: @ihsanzainal84’s method below is much simpler and cleaner, and doesn’t rely on backend workflows, so I’d recommend that method instead of this.

1 Like

Really creative solution! Your right that might not be a good solution for scale though.

1 Like

Haven’t tried this yet, just thinking from the top of my head.

Instead of using backend capacity you can do it client side. Just have a new User field for a date.

Create a workflow that updates that date field to the current time every minute (or whatever time interval u prefer).

You can define a user is online as long as that date field is no more than 1 minute of the current time. Again the time interval is up to you.

You can put this in a reusable element like a header or an empty group so u don’t have to repeat the workflow for multiple pages.

This uses a lot less capacity.


Perfect… great solution, much simpler and works just as well…

Just to add (for anyone reading this in the future), if you want to display a list of users, with those who are ‘online’ at the top, you’ll need to do two searches with a :merged operator (as you can’t use sorted by the ‘last online’ field unless you want the list to keep changing order every time the field gets updated).

So do a search for Users who’s last online date is less than 1 minute ago (or whatever your cut-off time is), merged with a search for all users, and add unique elements. That will keep the ‘online’ users at the top of the list without reordering them all the time.


Would having a workflow that updates 2 fields on the user every 60 seconds hurt capacity, UX, or interfere with other workflows running?

Also… if the workflow is in the header… and it’s set to run every 60 seconds… would switching pages start the 60 seconds over? I imagine so.