A brief analysis of path and domain in cookies

Source: Internet
Author: User

  This article is mainly to the cookie in the path and domain in a detailed analysis of the introduction, the need for friends can come to the reference, I hope to help you.

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– safety. 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.   IFYou 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.  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.