How to Prevent Concurrent User Logins in PHP/MySQL Site?

后端 未结 6 1634
北恋
北恋 2020-12-16 18:58

I am developing the user management portion of a website that will host a webcast. The goal is to prrevent the same user nam (email address) from being used concurrently.

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 19:41

    The problem here is detecting the user is logged in (i.e. whether he didn't logout).

    One possible way is to register in the database the time of his last activity and the time of his explicit logout. You could then deny a login if it this was attempted less than say 5 minutes ago relatively to his latest activity and if he didn't login in between.

    You could force "activity" by having the website pages periodically poll the server with Javascript.

提交回复
热议问题