# Remove user sessions from a client

**URL:** <https://forum.keycloak.org/t/remove-user-sessions-from-a-client/28810>\
**Category:** Getting advice\
**Created:** [November 19, 2024, 12:31pm UTC](https://forum.keycloak.org/t/remove-user-sessions-from-a-client/28810 "2024-11-19T12:31:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taxhi](https://avatars.discourse-cdn.com/v4/letter/t/bbce88/32.png) [@Taxhi](https://forum.keycloak.org/u/Taxhi)\
**Post date:** [November 19, 2024, 12:31pm UTC](https://forum.keycloak.org/t/remove-user-sessions-from-a-client/28810/1 "2024-11-19T12:31:38Z")

</div>

I want to remove all the users sessions only for the specify client in Keycloak but I am not finding a way. What I did until now is as below:

```auto
List<UserSessionModel> userSessions = session.sessions()
                                             .getUserSessionsStream(realm,client)
                                             .collect(Collectors.toList())
for (UserSessionModel userSession : userSessions) {
    AuthenticatedClientSessionModel clientSession = userSession.getAuthenticatedClientSessionByClient(client.getId());
    userSession.removeAuthenticatedClientSessions(Collections.singleton(client.getId()));

}

```

How can I fix this?

I am trying to find a solution for this.
