How to make user login from only one device at a time

后端 未结 7 2878
予麋鹿
予麋鹿 2021-02-04 16:47

I have a RestAPI which when hit authenticate the user. This api is exposed to android and ios developers they hit this api to allow user to login to our app

My requireme

相关标签:
7条回答
  • 2021-02-04 17:37

    php example

    When user success login

    $t1 = time();
    
    $t2 = $t1 +10
    
    Save $t1 in redis server
    
    Save $t2 in browser cookie (encrypted, only server know how to decrypt it)
    

    Whenever browser visit server always compare that $t2 > $t1, if not send browser message "you are logout"

    0 讨论(0)
提交回复
热议问题