# Restrict multiple devices for a user

**URL:** <https://community.auth0.com/t/restrict-multiple-devices-for-a-user/152421>\
**Category:** Get Help\
**Tags:** sessions, logout\
**Created:** [November 23, 2024, 8:44pm UTC](https://community.auth0.com/t/restrict-multiple-devices-for-a-user/152421 "2024-11-23T20:44:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thushalya](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thushalya/32/62532_2.png) [@thushalya](https://community.auth0.com/u/thushalya)\
**Post date:** [November 23, 2024, 8:44pm UTC](https://community.auth0.com/t/restrict-multiple-devices-for-a-user/152421/1 "2024-11-23T20:44:18Z")

</div>

Is there a way to restrict users to use only one device at a time? For example, if a user logs in on Device A and then attempts to log in on Device B, they should automatically be logged out from Device A.

I am using a microservices architecture and token-based authentication (specifically the passwordless grant type). Here’s what I am considering as a solution:

1. For every user request, decode the ID token to retrieve the session ID. Then, call the Auth0 endpoint to get the session ID and check if it exists. If the session ID is valid, grant permission for the request.

2. For every login attempt, check if there are any existing sessions for the user. If there are, delete all previous sessions while keeping only the new session active. I believe this can be achieved using Auth0 Actions.

please correct if I am wrong

---

<div class="post-metadata">

**Author:** ![ale.vesga1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ale.vesga1/32/60921_2.png) [@ale.vesga1](https://community.auth0.com/u/ale.vesga1)\
**Post date:** [December 5, 2024, 2:14am UTC](https://community.auth0.com/t/restrict-multiple-devices-for-a-user/152421/2 "2024-12-05T02:14:04Z")

</div>

Hi @thushalya

Welcome to the Auth0 by Okta Community!

Auth0 does not natively support limiting the number of sessions at the moment. I’ve checked internally and there is an existing backlog item to implement this feature.

However, the following information can help in your custom approach.

- The Management API provides access to attributes of the user sessions in the [Auth0 Session Layer](https://auth0.com/docs/manage-users/sessions/session-layers), which includes methods to terminate a session. See [Manage User Sessions with Auth0 Management API](https://auth0.com/docs/manage-users/sessions/manage-user-sessions-with-auth0-management-api#management-api-endpoints) for the endpoints in the Management API.

- There also exists a Management API endpoint to retrieve a user’s device credentials. See [Auth0 Management API v2](https://auth0.com/docs/api/management/v2/device-credentials/get-device-credentials). This is based on the `event.request.user-agent` attribute from the Event Object. See [Actions Triggers: post-login - Event Object](https://auth0.com/docs/customize/actions/explore-triggers/signup-and-login-triggers/login-trigger/post-login-event-object).

Hope this helps!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 19, 2024, 2:14am UTC](https://community.auth0.com/t/restrict-multiple-devices-for-a-user/152421/3 "2024-12-19T02:14:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
