path– path. Specifies the Web page associated with the cookie.
The value can be a directory, or a path.
If http://www.jb51.net/test/index.html establishes a cookie, then all pages in the http://www.jb51.net/test/directory, This cookie is accessible to pages in any subdirectory below the directory.
This means that any page in the HTTP://WWW.JB51.NET/TEST/TEST2/TEST3 can access cookies created by http://www.jb51.net/test/index.html.
But what if http://www.jb51.net/test/needs to access the Cookes of http://www.jb51.net/test/index.html settings?
At this point, we will set the cookie's path attribute to "/". When you specify a path, all Web pages that come from the same server with the same path in the URL can share cookies.
domain– domain. Specifies the associated Web server or domain.
Values are domain names, such as Www.jb51.net. This is an extension of the path Path property. What if we want www.jb51.net to be able to access cookies set by bbs.china.com? We can set the domain property to "china.com" and set the Path property to "/".
secure– safe. Specifies how the value of the cookie is passed between the user and the Web server over the network.
The value of this property is either "secure" or empty. By default, this property is null, which means that data is passed using an unsecured HTTP connection. If a cookie is marked secure, it passes data between it and the Web server through HTTPS or other security protocols. However, setting the secure attribute does not mean that other people cannot see cookies stored locally on your machine. In other words, setting the cookie to secure only guarantees that the cookie is encrypted with the data transfer process between the Web server, while the locally stored cookie file is not encrypted. If you want to encrypt the local cookie, you have to encrypt the data yourself.
expires– Expiration time. Refers to the lifetime of the cookie, which is exactly the expiration date.
You must use this property if you want the lifetime of the cookie to exceed the session time of the current browser. When the expiration date is passed, the cookie file is automatically deleted by the browser.