I have a rest API developed using php and mysql.
I need manage different client apps including Android and iPhone. I just want to allow only one user from one type of device.
For instance: if a user is using the app on Android and iPhone at the same time, this can be allowed. However, if a user tries to use the app more than one time on the same device, either Android or iPhone, it would not be allowed.
How I can achieve this? I am issuing 3 types of tokens at a time, such as token_iphone
, token_android
, etc. Currently my problem is, if any user logged in from the same type of device, the first instance the user started get its token expired or replaced with the new one.
Any help would be highly appreciated.
If i were you I'd manage this with memcached, you create an array identified by the username key and for each token you add to this array a couple device => token, when you have a conflict you either pull the correct token from the array or block the new device. if you have several servers you could also mange php sessions via memcached
User_a {
iphone: 12345,
android:67890,
pc: abcdef
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With