urlcookieshttpcookieglobal-pathurl-path

Cookie path and its accessibility to subfolder pages


Let's say I have a website with domain: www.example.com

If I set a cookie with path '***/***' the cookie will be accessible via all pages in the domain, eg:

What if we set the cookie to path '/subfolder1', will the cookie will be made available to any page or subfolder beneath the folder? Eg:

So, if not, I guess, I have no choice but to use path '/' for those cookies, right?


Solution

  • If we set the cookie to path '/subfolder1', will the cookie will be made available to any page or subfolder beneath the folder?

    Yes. The cookie will be available to all pages and subdirectories within the /subfolder1 path.