-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ktor server invalidate session #4727
Comments
The Have you experienced any problems while implementing the solution? |
Yes, I have read the current documentation but "clear" doesn't cover the above use case.
As I understand, "clear" removes the current session for the user (e.g. with this specific session id). How can I clear the other old sessions for this user before starting a new one. |
Can you please tell me how you determine if the same user sends requests from the multiple devices? |
Unfortunately, it is impossible to invalidate the user's other sessions. The main reason is that Ktor doesn't provide control over how to generate the session ID based on the cookie's or the header's content. If it did, you could send the client ID, which is the same across all user's devices, along with the device ID, and on the server using the Should I file a feature request to address this limitation? |
For example, I use
Preferably, I would like to determine with some custom predicate all other sessions using my user session class (for my case all sessions associated with the userId) before setting a new one and clear them.
Yes if possible. Thanks |
This approach requires traversing all session storage to find the sessions of the same user, which is inefficient. I thought of using the user ID as a key for the faster lookup. What do you think? |
Not sure if i want to expose the userid in the session id. But if you can provide control how to generate session id with e.g. the user session object I can somehow associate the generated session IDs with userid. Also, in clear you may need to provide new function to handle session id(s) as an argument. |
Is it possible to invalidate all the other session for a user when he/she creates a new session ?
The use case is like this:
e.g. the user logins in one device (mobile or web) and a new session is created from server.
Then the same user logins from another device (mobile or web) and creates a new session. The session from the old device needs to be invalidated and only the session from the new device should be active.
| searched the sessions plugin and authentication/session but now sure if this is possible right now.
The text was updated successfully, but these errors were encountered: