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!