PHP 登录系统,如 yahoo Messenger
我将使用 php 创建登录身份验证,要求是:一个用户名帐户不能同时登录,如果发生这种情况,第一个登录用户应自动注销。就像雅虎通一样。这个概念实际上是怎样的?,使用 PHP 实现此目的的最佳技巧是什么?
谢谢。
I would create a login authentication using php, The requirement is : one username account can't login at the same time, if this occur the first login user should logout automatically. Just like yahoo messenger do. How is the concept actually ?, What the best trick to do this with PHP ?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将上次登录的会话 ID 存储在数据库中。当用户下次登录时,旧会话将失效,并将新创建的会话 ID 存储在数据库中。例如:
You need to store the session ID of the last login in your database. When a user logs in the next time, you invalidate the old session and store the newly created session ID in the database. For example:
此外,您不需要同时保存新旧会话。在你的数据库中只有一个会话。
当用户登录时更新您的会话值。在检查会话的代码之后。之前的登录将自动失效。
additionally you dont need to save both old and new session. just have one session in your db.
when the user logs in update your session value. after code for check session. The previous login will be automatically invalidated.