Session Start
Session_Start (); Start a session, if you want to use the session program, you must add this sentence
$_session[' user_id ' = ' 123 ';//Assign a value to a SESSION variable if the variable does not exist to create
echo $_session[' user_id '];//access SESSION variable
$_session = Array ();//clears all SESSION variables
Session_destroy ();//clear session ID
Session End
Cookie Start
Setcookie (' user_id ', 123);//Create a cookie variable user_id=123
echo $_cookie[' user_id '];//access COOKIE variables and work variables
Setcookie (' user_id ', 0,time ()-1);//Delete cookie variable
Codie End
This code is not run, just use all the methods listed here, the actual should be different features on different pages to use, will be shown in the following example
?>
Session Start
Session_Start (); Start a session, if you want to use the session program, you must add this sentence
$_session[' user_id ' = ' 123 ';//Assign a value to a SESSION variable if the variable does not exist to create
echo $_session[' user_id '];//access SESSION variable
$_session = Array ();//clears all SESSION variables
Session_destroy ();//clear session ID
Session End
Cookie Start
Setcookie (' user_id ', 123);//Create a cookie variable user_id=123
echo $_cookie[' user_id '];//access COOKIE variables and work variables
Setcookie (' user_id ', 0,time ()-1);//Delete cookie variable
Codie End
This code is not run, just use all the methods listed here, the actual should be different features on different pages to use, will be shown in the following example
?>
Cookie,session is a way for Web applications to maintain user state
A cookie is information that is stored by the client and sent to the server when the client connects to the server.
Session is stored on the server side of the information, from this point of view session relative cookie more secure
When the session is created, the server returns an encrypted session ID to the client to identify the user, and the session ID is generally stored in the cookie when the cookie is not available by URL
The above code shows how to create and use session cookie variables
http://www.bkjia.com/PHPjc/364050.html www.bkjia.com true http://www.bkjia.com/PHPjc/364050.html techarticle ? PHP//Session start Session_Start ();//Start a session, if you want to use the session program first must add this sentence $_session[' user_id '] = ' 123 ';//Give a session Variable Assignment ...