Home > Database > Mysql Tutorial > Cookie attribute and method analysis

Cookie attribute and method analysis

一个新手
Release: 2017-09-19 10:03:28
Original
1648 people have browsed it

Detailed explanation of cookie attributes

You can see cookie information in the resources tab in the chrome console.

There may be many cookie objects under a domain name. The

name field is the name of a cookie. The

value field is the value of a cookie.

domainField is the domain name that can access this cookie.

For non-top-level domain names, such as second-level domain names or third-level domain names, the domain of the cookie set can only be the top-level domain name or the second-level domain name or the third-level domain name itself. Cookies for other second-level domain names cannot be set, otherwise the cookie will be set. Unable to generate.

The top-level domain name can only be set to the top-level domain name, and cannot be set to the second-level domain name or the third-level domain name, otherwise the cookie cannot be generated.

The second-level domain name can read cookies that set the domain to the top-level domain name or its own, but cannot read the cookies of other second-level domain names. Therefore, if you want cookies to be shared among multiple second-level domain names, you need to set domain as the top-level domain name, so that the value of this cookie can be found in all second-level domain names.
Top-level domain names can only obtain cookies whose domain is set to the top-level domain name. Cookies whose domain is set to the second-level domain name cannot be obtained. The

path field is the path of the page that can access this cookie. For example, if the domain is abc.com and the path is /test, then only the pages under the /test path can read this cookie.

expires/Max-Age The field is this cookie timeout. If its value is set to a time, then the cookie will expire when this time is reached. If not set, the default value is Session, which means that the cookie will expire together with the session. When the browser is closed ( is not the browser tab, but the entire browser) Afterwards, this cookie expires.

Size Field The size of this cookie.

http Field The httponly attribute of the cookie. If this attribute is true, this cookie information will only be included in the http request header, and this cookie cannot be accessed through document.cookie.

secure Field setting whether this cookie can only be delivered through https

The above is the detailed content of Cookie attribute and method analysis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template