Is there an SDK to fetch all active session like t...
# support-questions
a
Is there an SDK to fetch all active session like the one in the Saas? Not based on a single user.
r
Hey. There ain’t such a function yet. If you open an issue about this on the core repo, we can make a pagination function for this.
What you can do is loop through all the users, and then for each, fetch all the sessions. This way, you can get all sessions
a
owh okay... then just check which session is active and not
r
well, it will return only active sessions, in the sense the ones that have a valid refresh token.
a
ahh nice then thank you
hey, backing to this question I tried looping and use getAllSessionHandlesForUser but as you say that it only returns the active session. But I want to get a total number like that, that record a total active session in a given period.
is there a way to do that?
when user logout, this getAllSessionHandlesForUser return empty
r
Hmm. You will have to setup a cronjob on your end that regularly keeps track of the sessions for each user and then uses that data to calculate number of active sessions for a time period. That’s kind of what we do to calculate number of active sessions for a time period.
a
owh okay, because when I check the session got delete in DB when a user is signout
r
Yup. So you will have to save sessions somewhere else as well so that you can calculate active sessions
2 Views