Prevent multiple login using the same user name and password

前端 未结 12 2577
栀梦
栀梦 2020-11-29 22:03

I am developing an application that needs to prevent multiple login using the same user name and password.

If it happens on the same machine then obviously we need t

12条回答
  •  野性不改
    2020-11-29 22:30

    Use the token

    When user logins success, the server side returns a token string to client/browser side, and server side saves a map with userID - token. The client repeatedly checks/requests to server with that token, if the token is not same, this user logs multiply times.

    When logoff, it saves the token into cookies or file system in the client side, and brings this token when loging next time.

    Table:

    userid:token:log_date
    

提交回复
热议问题