浏览器存储
作者: ljianshu创建于 2018年10月11日更新于 2023年3月9日
标签Browser
- name: The unique name of the cookie. Cookie names are case-insensitive, so myCookie and MyCookie are the same name. However, in practice, it is best to treat cookie names as case-sensitive, because some server software may treat them as such. The cookie name must be URL-encoded.
- value: The string value stored in the cookie. This value must be URL-encoded as well.
- Domain: The domain to which the cookie is valid. All requests to that domain will include the corresponding cookie. If not specified, the default is the document source (defined by the protocol, domain name, and port), and does not include subdomains. If Domain is specified, it generally includes subdomains. Thus, specifying Domain has fewer restrictions than omitting it. However, when subdomains need to share information about the user, this can be helpful. For example, if you set Domain=mozilla.org, the cookie will also be included in subdomains (such as developer.mozilla.org).
- Path: Request URLs that contain this path will send the cookie to the server.
// For example, setting Path=/docs, the following addresses will match:
/docs
/docs/Web/
/docs/Web/HTTP- Expires/Max-Age: Sets the cookie expiration time (Expires) or lifetime (Max-Age) (i.e. when it will no longer be sent to the server). Cookies in simple name/value pairs only exist for the current session, and are lost when the user closes the browser. If you want the cookie to have a lifetime beyond a single browser session, set Expires/Max-Age, with max-age taking precedence over expires.
内容来源: ljianshu/Blog