This article mainly introduces the PHP session control, combined with an example of PHP for the cookie and session related operation skills, the need for friends can refer to the following
Specific as follows:
The test code for the cookie and session:
<?phpsession_start ();d efine (' u ', ' a ');d efine (' P ', ' 1 '), if (Isset ($_get[' R ')) && $_get[' R ']== 1) {unset ($_ cookie[' username '); unset ($_cookie[' password '); unset ($_session[' Valid_login ');} if (isset ($_post[' username ')) && isset ($_post[' password ')) {$username = $_post[' username ']; $password = $_post[' password '); if ($username = = U && $password = = p) {$_session[' valid_login '] = 1; Setcookie (' username ', $username); Setcookie (' password ', $password); } else {echo ' incorrect u or P '; }}?><?phpif (Isset ($_session[' Valid_login ')) {printf (' welcom,%s ', $_cookie[' username ');} else {?>< Form action= "" method= "post" > <input type= "text" name= "username" value= ""/> <input type= "password" name= "pa ssWOrd "value=" "/> <input type=" Submit "/></form><?php}?><br/><a href=" Cookie_ session.php "title=" ">refresh</a><br/><a href=" cookie_session.php?r=1 "title=" ">clear</a >
The above is the whole content of this article, I hope that everyone's study has helped.