skip to Main Content

I want to identify who is on my app so I can place green badges as indicators.

I logged into my app (which I have not deployed) through Google OAuth, so the session is stored. However, I left days ago and it is still there. So, I don’t know the best algorithm or query to implement to accomplish this. Hopefully, other developers have been able to overcome this issue.

2

Answers


  1. In general a possibility you could opt for is to store the last request time for each user and consider anyone green by default whose latest request happened in the latest 30 minutes or so. Of course, some scenarios may override it, such as a user clicking on logout could be set to inactive even if he had quite recent requests.

    Or, if you use WebSockets, then you could track who has open channels.

    Login or Signup to reply.
  2. If you want to display the list of users that are online, presence is the feature built exactly for that.

    https://supabase.com/docs/guides/realtime/presence

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search