What is Cookie?
Cookie is a variable stored on the visitor's computer.
Cookies are small pieces of user information stored by Web servers in text files on users' computers. When a user accesses a Web server, the Cookies stored on the user's computer are read from the client to the server, the server develops services for users based on cookie information.
For example, when a website is accessed, the number of user logins is displayed on the page.
Cookie syntax
Set-COOKIE: name = value; [exprise = date]; [Path = dir]; [domain = domainname]; [secure]
Cookie attributes:
Name attribute:Required attribute, indicating the cookie name
Expires attributes:Determine how long the cookie will be maintained on the client before it is deleted
If no cookie is set, it is only useful for the current browser session,
When the user closes the current browser, the cookie will automatically disappear.
Path property:Determine the availability of cookies for other web pages on the server
By default, cookies are available for all pages in the same directory.
Set path: cookie is only valid for all webpages in the specified path and sub-path.
Domain attributes:Set multiple servers in the same domain to share one cookie.
Secure attributes:Indicates that cookies can only be transmitted over https or other secure Internet connections.
Cookie Storage
The information fragments saved by cookies are stored as "name/value" pairs.
Explanation: a cookie string can store up to 20 pairs of "name/value" pairs (name = value)
The cookie string must end with a semicolon.
Cookie category
Cookie can be temporary or permanent:
Temporary cookies are only applicable to the current browser session.
A permanent cookie automatically generates a text file on the client's computer, and can be used outside the current browser.
A permanent cookie is a file stored on the user's hard disk. This file usually corresponds to a domain name,
When the browser accesses this domain name again, the cookie is available.
Cookie file name
Generally:[Email protected]
User: Local User Name
Domain: the Domain Name of the accessed website
Cookie usage:
Save logon status
Tracking user behavior
Create a shopping cart
Conduct a public opinion Test