How to prevent multiple logins in PHP website

前端 未结 7 1710
独厮守ぢ
独厮守ぢ 2020-11-30 23:10

I want to prevent multiple logins in a php application.

First, I create login status (active, notactive) in a user table.

When user A logs in the user status

相关标签:
7条回答
  • 2020-12-01 00:10

    You need to create a unique ID and store that in a database. What I did was create too. I store one in a session variable and use that to prevent session hijacking and another in a database to prevent multiple logins. The following code will create a unique ID:

    $unique_id = sha1('xzr4'.gethostbyaddr($_SERVER['REMOTE_ADDR']).$random_string.$_SERVER['HTTP_USER_AGENT'].'f8k2');
    

    If the unique ID doesn't match, you simply log the user out.

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