Solved

How to limit number of devices which are using the same user id?

  • 17 November 2021
  • 1 reply
  • 210 views

Badge +1

Hi there,

I want to know how should I be able to limit the number of devices with the same user id , and block the subscription provided after that on another device.

Like Netflix and Amazon does,  they only allow streaming on maximum 2 to 3 devices simultaneously on  there Standard plan.

icon

Best answer by ryan 18 November 2021, 03:34

View original

1 reply

Userlevel 5
Badge +9

Hey @Kunal!

I think this is typically solved through whatever authentication provider your are using, or building something custom on your end to manage sessions.

The general flow could be:

  1. Customer logs in, you generate a “Session ID” and save it as the first item in an array on your customer object and in local storage on the device.
  2. If the “Session ID” array on the customer object in your database ever exceeds 3 (or however many devices you want to limit) throw out the oldest session ID.
  3. Every time the customer opens the app, check that the Session ID in local storage exists in the Session ID array on the customer object from your database. If not, log out the customer and make them re-authenticate (which would logout someone else).

There are ways customers could hack this, by sharing session IDs and overwriting local storage, but could be a good place to start for what you’re after.

Curious to hear if anyone else has implemented something similar.

Reply