How to get a list of recently logged-in users

Hello developers,

We are an indie development team making great use of the Nakama server.

As we proceed with our release, there’s a feature we need and wanted to inquire about.

The feature is a way to get the recently logged-in users.

We wish to implement a real-time league feature.

If possible, we’d like to obtain a list of users currently online or those who have recently logged in (around 500 users) to create a league.

How can we do this?

This translation should convey your message clearly to English speakers familiar with Nakama or other server development contexts.

Hello @Gandangf,

You can implement a list of recently logged-in users with Storage Engine Search.

You can use an after hook to store a timestamp of the latest login in an existing or new storage object for your user. If needed you can also create a custom RPC to allow the client to update this value whenever the user connects if your sessions are very long.

Make sure you set up the storage search such that this timestamp is indexed, and then you can use its listing api to lookup timestamps within some timerange using the query syntax.

Hope this helps.

ank you so much. Your assistance has been invaluable. Our league is becoming perfect. Thank you.