|
|
|
|
|
|
|
|
|
|
|
|
|
Cookies |
Session
|
Storage location
|
stored in the browser |
The real file exists on the server , K exists in browser |
Security
|
Low, easy to forge |
Higher security than cookies |
Set up
|
Setcookie () function |
Session_Start () after passing through PU Pass function operation |
Available Storage type
|
Scalar type: int, float, char, bool, NULL |
All types except Resources |
Life cycle
|
Set by the third parameter such as: Setcookie (' School ', ' XTU ', Time () +15);
|
Set by php.ini file Session.cookie_lifetime Session.gc_maxlifetime
|
Valid path
|
Set by the fourth parameter Setcookie (' School ', ' Kefeng ', Time () +5, '/');
|
Depends on the valid path of the cookie PHP.ini can be configured in: session.cookie_path=/
|
Valid domain name
|
Set by the fifth parameter String ' www.example.com '
|
Depending on the valid domain name of the cookie PHP.ini can be configured in: session.cookie_domain=
|
Read
|
$_cookie["] |
$_session["] |
Destroyed
|
Setcookie (",", 0) Setcookie (",", Time ()-1)
|
Four methods of Destruction: 1. Destroy a unit: unset ($_session[' School '); 2. Overall Clearance: $_session = Array (); 3, the use of the overall elimination of functions: Session_unset (); 4, the boxes are not: Session_destory ()
|
Principle |
Between the browser and the server The server in the data interaction Data is transmitted via HTTP headers To the browser next time Exchange Over HTTP headers to the server |
Store k in this process (Number of browser-to-server (interactive) v is stored on the server In the process, the browser and the service The data that the service interacts with is K. |
The above describes the cookie and session summary, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.