Cookie learning ------- Introduction

Source: Internet
Author: User


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











Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.