How to design an account that can only log in with one terminal?

such as title:
my own logic:
1. Add a field is_online to the user table (whether you have logged in 0 but not logged in 1)
2. Determine whether this field is 1 when logging in, and update this field to 0

when you exit.

if the user exits abnormally (closing the browser, etc.), it will be impossible to update the is_online field

at present, I have come up with a method: but I don"t fully understand

.

is to determine whether the session_id in the database exists in the server when session_id is stored in the database and logged in?

how to do this, please ask

Php
Mar.03,2021

each login generates a user user_id and a relative token, to be saved in the database. Determine whether the token is valid before each API request. When the token changes after re-login, the token verification of the previous login is invalid, thus realizing that an account can only log in with one terminal.


after each login, a time-limited token, is generated and saved on both the server and the client, and only this token
is verified each time. After a new login event occurs, due to the change of token, the previous valid login is automatically invalidated


.

when logging in, session_id is stored in the database for authentication to determine whether the session_id in the database still exists in the server

get the directory path of session_id in the server through session_save_path ()

//
if($admin['is_online']) {
    // session_id    session30
    if(file_exists(session_save_path().'\\'.$admin['session_id'])) {
        ajaxmsg('',0);
    }
}

https://github.com/zhangrenji.


our website uses memcache sharing session


jwt

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c27c-2c2e9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c27c-2c2e9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?