Previous article: success! What is Cookie and Session? A: storage mechanism !!! Cookie: from the web page...
Previous: http://www.2cto.com/kf/201205/131555.html
The reason is that the previous BLOG writing system was unsuccessful. I need to understand the basic mechanism.
Start with Cookie and Session!
What is Cookie and Session?
A: storage mechanism !!!
Cookie: the data transmission method from the Web page to the Web page. the Client exists.
Session: a method to ensure that data remains valid on the page.
Session mechanism-tracking users based on a session on a website
Allows users to log on and display information based on their interests.
PHP session-a unique session ID to drive.
This ID is an encrypted random number.
The session will be stored on the client during its lifecycle.
Stored in cookies and transmitted through URLs on the Internet
Talk about cookies first
Overview:
A mechanism for storing data on a remote browser to identify and track users
Will exist on the user's hard disk. when the user logs on again, it will read the specific information
Format: user name: @ 网 ]]digital *.txt
Function:
Record Visitor Information
Transfer variables between pages
Store the viewed page in the Cooike folder to speed up re-access.
Usage:
Create: setcookie (name, value, expire, path, domain, secure)
Parameter description
| Parameters |
Description |
| Name |
Required. name |
| Value |
Required. cookie value |
| Expire |
Validity period |
| Path |
Server path |
| Domain |
Domain name |
| Secure |
Whether to transmit data over https |
Read: $ _ COOKIE ['XXX'] Read
Delete:
Use setcookie (); setcookie ("name", "", time ()-1 );
Let's look at the SESSION.
Overview:
Prevent users from logging on to each opened page and using Session
The session is stored on the client, which is more efficient than the cookie during verification (you do not need to go to the Database to check the information every time)
Usage:
Start: session_start ();
Use: $ _ SESSION ['name'] = "Matter ";
Delete:
Unset ($ _ SESSION ['name']); // deletes a single attribute.
Session_destroy (); // delete the entire session and clear all resources!
$ _ SESSION = array (); // delete all sessions
From matter605924657