Allow one session only at a time

后端 未结 6 1316
予麋鹿
予麋鹿 2020-11-28 13:23

I would like to make my website to allow only one session at a time. For example, let say user has login to my website on firefox, if the user login again to another browser

6条回答
  •  春和景丽
    2020-11-28 13:36

    Store session id in the database. retrieve last login session id from db, set session id using session_id(oldid) and change session variables related to authentication like $_SESSION['LOGIN'] and destroy the session and create new session with new session id. follow example for logic https://www.php.net/manual/en/function.session-create-id.php. this will make the last login allowed. validate on each page session variables related authentication. this makes it session invalid because of this session_id reset by a new login.

提交回复
热议问题