How to check if user session is active from Express API?

Hi,

How can I check if the user is currently active from the backend(Express)?

Use case:
The express server has a cron job that checks if the user session is active and runs some method.

Options:
The simplest option is probably to push logged-in timestamp to the database in intervals using an API from the react app and express cron check the database timestamp. If the timestamp is in the ballpark of the current time, it executes the method.

However, I believe there could be a better way.
Like when the express cron executes, it can somehow get the users with currently active sessions/logged-in users and performs the desired function.

Any tips or recommendations?
Thanks!

Hi there!

Welcome to the Auth0 Community!

To validate session from the back-channel, our recommended way is to use the GET /api/v2/sessions/{sessionId} Manage User Sessions with Auth0 Management API.

Alternatively, you might find our OIDC Back-Channel Logout feature interesting since it allows your backend to subscribe to logout events. → OIDC Back-Channel Logout

Thanks
Dawid

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.