The answer to this question about how cookies are potentially vulnerable between sub-domains sparked my curiosity.
As far as I know, if a cookie is set on a sub-path of the same domain (
www.example.com/dogs), then it is not accessible to any other path, unless it's a sub-folder of the path. i.e. neither
www.example.com/ should have access to those cookies, but
Reading further, I see it's possible to get the cookies from different paths:
It is important to note that the path restriction does not protect against unauthorized reading of the cookie from a different path. It can easily be bypassed with simple DOM (for example by creating a hidden iframe element with the path of the cookie, then accessing this iframe's contentDocument.cookie property). The only way to protect cookie access is by using a different domain or subdomain, due to the same origin policy.