Cookie 路径及其对子文件夹页面的可访问性 [英] Cookie path and its accessibility to subfolder pages
问题描述
假设我有一个域名:www.example.com
Let say I have a website with domain: www.example.com
如果我设置了路径为/"的 cookie,该 cookie 将可以通过域中的所有页面访问,例如:
If I set a cookie with path '/' the cookie will be accessible via all pages in the domain, eg:
- www.example.com/page1.html
- www.example.com/subfolder1/page1.html
- www.example.com/subfolder1/moresubfolder1/page1.html 等
如果我们将 cookie 设置为路径 '/subfolder1' 会怎样,该 cookie 将可用于文件夹下的任何页面或子文件夹吗?例如:
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:
- www.example.com/subfolder1/moresubfolder/page1.html
所以,如果没有,我想我别无选择,只能为这些 cookie 使用路径/",对吗?
So, if not, I guess, I have no choice but to use path '/' for those cookies, right?
推荐答案
如果我们将 cookie 设置为路径 '/subfolder1',cookie 将可用于文件夹下的任何页面或子文件夹吗?
If we set the cookie to path '/subfolder1', will the cookie will be made available to any page or subfolder beneath the folder?
是的.cookie 将可用于/subfolder1
路径内的所有页面和子目录.
Yes. The cookie will be available to all pages and subdirectories within the /subfolder1
path.
这篇关于Cookie 路径及其对子文件夹页面的可访问性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!