https://supertokens.com/ logo
a

ashlite

06/18/2022, 1:10 PM
Is there an SDK to fetch all active session like the one in the Saas? Not based on a single user.
r

rp

06/18/2022, 1:16 PM
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

ashlite

06/18/2022, 2:05 PM
owh okay... then just check which session is active and not
r

rp

06/18/2022, 2:05 PM
well, it will return only active sessions, in the sense the ones that have a valid refresh token.
a

ashlite

06/18/2022, 2:09 PM
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

rp

06/19/2022, 10:51 AM
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

ashlite

06/19/2022, 10:54 AM
owh okay, because when I check the session got delete in DB when a user is signout
r

rp

06/19/2022, 10:55 AM
Yup. So you will have to save sessions somewhere else as well so that you can calculate active sessions
2 Views