How to know if a user is online?

Hello,

Does anyone know how I could know if a user is currently online ? I have a list of users displayed on a page, and I would like to indicate if the user is online or not.

Thanks,

Baptiste

If think you’ll have to use your backend for this. But maybe, you could have an endpoint checking if a user token (like the bearer token) was used during the last X seconds/minutes/hours.

For example, let’s say a user is connected. On every page change, he or she is triggering a getMe endpoint so that the WeWeb app knows who he or she is. In your backend, you could then check if the getMe endpoint was triggered by this user for the last 60s for example.

1 Like