Php session code
The Code only uses SID to determine whether the cookie or session is used.
; // The jump page cannot be the header if (isset ($ _ POST [sub]) {include conn. inc. php; $ SQL = select id from users where name = '{$ _ POST [name]}' and password = '. md5 ($ _ POST [password]). '; $ result = $ mysqli-> query ($ SQL); // Save the data if ($ result-> num_rows> 0) {$ row = $ result-> fetch_assoc (); $ _ SESSION [username] =$ _ POST [name]; $ _ SESSION [uid] =$ _ POST [uid]; $ _ SESSION [isLogin5] = 1; // jump interface echo '<script>'; | r | echo location = 'index. php ?. SID. '; // SID constant: If the cookie is enabled, the cookie is used. If the cookie is not enabled, the session | r | echo' </script> ';} The echo username and password are incorrect.}?>
Conn. inc. php
comm.php
Index. php
. $ _ SESSION [username]. Hello! This is the homepage of the website; echo session_id ().; echo your permissions are as follows:; $ SQL = select allow_1, allow_2, allow_3, allow_4 from users where id = '{$ _ SESSION [uid]}'; $ result = $ mysqli-> query ($ SQL); $ user = $ result-> fetch_assoc (); if ($ user [allow_1]) {echo 111111111111 ;} if ($ user [allow_2]) {echo 222222222222;} if ($ user [allow_3]) {echo 333333333333;} if ($ user [allow_4]) {echo 444444444444 ;}?> > Page 2> page 3> exit
The compiling of test. php and test2.php is exactly the same as that of index. php.