the path to the cookie and the cookie domain
Cookie Path
Cookies are typically created by the user accessing the page, but not only on the page where the cookie is created. By default, for security reasons, only pages that are in the same directory as the page in which the cookie was created or on the subdirectory where the cookie page was created are accessible. Then you need to set the path if you want its parent or the entire Web page to be able to use cookies.
A method of making the cookie for this setting accessible to other directories or to the directory of the parent:
Document.cookie = "UserName = Lone ice sea; path=/";
Cookie Domain
The path solves the problem of accessing cookies under the same domain, so how do you solve the access problem under the same primary domain? We can set it by specifying a host name that can access the cookie.
Document.cookie= "Name=value; Domain=cookiedomain ";
For example, "www.baidu.com" and "mp3.baidu.com" common an associated domain name "baidu.com", if we want to "www.baidu.com" cookies under "mp3.baidu.com" access, we need to use The domain property of the cookie, and you need to set the Path property to "/"
Here is a point to note: A certain is the access between the same domain, can not set the value of domain to the domain name of the non-primary domain.
The default cookie domain is the current domain name, and the default Path setting cookie is the current page's directory path. If you want to access a cookie across a domain or under another path, you must reset both properties, domain, and path.
www.baidu.com/content/example/3.jsp field domain is www.baidu.com, path is/content/example
Document.cookie = "username= lone ice Sea; path=/; Domain=baidu.com "