Php effectively prevents the same user from logging on multiple times, and php effectively prevents logon. Php effectively prevents the same user from logging on multiple times. php effectively prevents logon [problem description]: it is dangerous to log on multiple times for the same user at the same time if it cannot be detected. Because, you do not have php, which effectively prevents the same user from logging on multiple times, and php effectively prevents logon.
[Problem description ]:It is dangerous for a single user to log on multiple times at the same time. Because, you cannot know if other users are logging on to your account. How Can I disable multiple logins from the same user?
[Solution]
(1) A new session_id is generated after the identity authentication is successful upon each login.
session_regenerate_id(); session_register ("username") ;
(2) open a sessionid field in the user database. after the session_id is re-generated, the field is updated.
$sessionid = session_id(); $db = new PDO('sqlite:softToken.db'); $sql = "update userinfo set sessionid ='$sessionid' where username='$username' and passwd='$passwd';"; $query = $db->prepare($sql); $query->execute();
(3) Create a session to save the user name
$_SESSION["username"] = $username;
(4) use url rewriting to pass session_id
$ Url = "main. php? Sid = ". session_id (); unset ($ db); echo" login successful, jump! "; Header (" Location: $ url ");
(5) add
Main. php
<? Php header ('content-type: text/html; charset = utf-8 '); $ sessionid = $ _ GET ['Sid']; session_id ($ sessionid); session_start (); $ username = $ _ SESSION ["username"]; $ db = new PDO ('sqlite: softToken. db'); $ SQL = "select * from userinfo where username = '$ username' and sessionid =' $ sessionid ';"; $ query = $ db-> prepare ($ SQL); $ query-> execute (); $ user = $ query-> fetch (PDO: FETCH_OBJ ); if ($ user-> username = "") {session_destroy (); echo"