PHP session Add, Delete, modify, view operation, Phpsession
The difference between a session and a cookie is that the cookie file is stored on the client, and the session is stored on the server, and in contrast, the session is more advantageous for a certain amount of security.
Because the session in the server side of the general situation is the management of the server, but the cookie is in the client's save, anyone can see, if not specified, the password is also clear text preservation, security is obvious.
And the session is relatively more powerful, you can save the array, and even the object, in a way, can reduce the development cost.
Here is the code used for the session:
Increase of Session data:
Copy the Code code as follows:
<?php
Header ("content-type:text/html; Charset=utf-8; "); /utf-8 display, not related to session
Session_Start ();//Start session data Save
$_session[' name ']= "xuning"; *//add SESSION data.
?>
Deletion of session data.
Copy the Code code as follows:
<?php
Header ("content-type:text/html; Charset=utf-8; "); /utf-8 display, not related to session
Session_Start ();//Start session data
unset ($_session[' name ']= "xuning"); *//Delete SESSION data.
Session_destory ();//Delete all session
?>
The session is modified to increase the session data.
The session data is viewed, i.e. the session data is removed.
Copy the Code code as follows:
<?php
Session_Start ();
Print_r ($_session);//Get SESSION
echo $_session[' name '];
?>
Either the cookie or session ends at the end of a session, which closes the browser and ends the session.
http://www.bkjia.com/PHPjc/970994.html www.bkjia.com true http://www.bkjia.com/PHPjc/970994.html techarticle PHP session to add, delete, modify, view operation, phpsession session and the difference between the cookie is the first, the cookie file is saved on the client, and the session is saved in the server ...