Cookies
//Set Cookies$uid= "Admin";$pwd= 123;Setcookie("UID",$uid, Time() +24*60*60);//The variable is stored in a cookie, the first parameter variable name (string), the second parameter variable value (can also be directly written value), and the third is the deposit time (not written by default when the browser is closed)Setcookie("pwd",$pwd, Time() +24*60*60);//Delete CookiesSetcookie("pwd", "", Time()-1);//also use this function, just change the time to the time before now
Session
//setting Session//session_start () cannot have any output in front of it, this function sends a SESSION_ID presence cookie to the client and establishes a session text file on the server side and saved in the cookie scheduling PHP mechanism using sessionSession_Start();//using the $_session array$_session[' uid ']= ' admin ';$_session[' Age ']=18;Print_r($_session);//output Session Global arrayEcho Session_name()." =".session_id();//Show session name&id//clear SESSION//1. Use unset to delete eachunset($_session[' UID ']);//2. Delete all the contents of the array$_session=Array();//3. Delete the SessionID in the customer cookieif(isset($_cookie[Session_name()]))//prevent the deletion of the mistake and judge it beforehand{ Setcookie(Session_name(),"", Time()-1, "/");}//4. Destroy the session, delete the user on the server side of the fileSession_destroy();
Basic knowledge of PHP session control