Table of Contents

Cookie - Scope

About

The scope of a cookie name is a calculated property defined by the concatenation of

If the request URL matches the scope (ie domain and path expression), the user agent (browser) will add the cookies in the Cookies header to the request returning it to the server (if the other cookie property (such as expiration date, http only,..) are also valid)

You can have the same name below differents scope.

Below you can see that their is 2 cookie named visits below two differents scopes.

Cookie Scope Name

Example

For instance:

Set-Cookie: key=value; Path=/; Domain=example.com

Cookies: key=value

Properties

Domain

The domain attribute determines the scope and determine which host (port excluded) are allowed to receive the cookie.

The scope rules are applied top down (ie applied to the domain and all subdomain)

If the domain property of the cookie is:

More … see The domain property of a cookie in depth

Path

The path attribute is a scope attribute and is matched against the request URL path where:

The default value of the path is the parent of the last name:

If several cookies shares the same name with different path, a list of values is returned ordered by scope order. For instance, suppose that

Cookie: visits=2; visits=3

As seen in the Cookie value, there is no way to know the path of the values.