C#C
C#3y ago
linqisnice

❔ Is there osme way to check if a user is active/online with aspnet core identity? (cookie)

Title is slightly incorrect: is there some way to check based on a users id if they are signed in*

I understand that when you sign in, a cookie is created and sent to the browser and is then validated on each specified request.

and then when you sign out, the cookie is invalidated...

so there's no concept of bein "signed in"...

in my situation, i need to check if x and y users are logged in inside a webhook request, and so there's no user request cycle here so i cant check the httpcontext if the request is coming from any given user.

So... my thought was that I could maybe update a flag in the db when a user logs in or out, but when they close their browser, they would still be signed in but inactive.

Is there soome "common" approach to this problem? how would a "last seen" function be implemented here?

Would global action filter or middleware with a lastseen property be good enough?
Was this page helpful?