且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何防止PHP/MySQL网站中的并发用户登录?

更新时间:2023-12-01 17:20:28

如果其他人可以使用相同的凭据登录,则可以注销已经登录的用户,则可以执行以下操作:当用户登录时,generate数据库中该用户的随机ID,并在 cookie 会话中使用相同的ID.两者必须匹配才能进行身份验证.

If it is OK to logout an already logged in user if someone else logs in with the same credentials then you could do the following: when a user logs in generate a random ID in your database for that user and the same in a cookie session. The two must match to authenticate.