|
The Cookies are Created in Week 1.
Three "TestPath" Cookies are Created.
- setCookie("TestPath",
"TestPath no path assigned", expdate);
- The Cookie "TestPath" is created with the Value "TestPath
and no path is assigned"
- When no path is assigned the path will
automatically be the current directory. This means that
directories beneath /coin70/week1 have the capability to read
this Cookie.
- setCookie("TestPath",
"TestPath Week 2", expdate, "/coin70/week2");
- The Cookie "TestPath" is created with the Value "TestPath
Week 2"
- Here we are
setting the path to /coin70/week2. This means that directories
beneath /coin70/week2 have the capability to read this Cookie.
Any directory not within week2 will not have access to this
particular cookie.
- setCookie("TestPath",
"TestPath /", expdate, "/");
- The Cookie "TestPath" is created with the Value "TestPath
/"
- Here we are
setting the path to the root. All directories will have access
this Cookie.
One "Week7" Cookie is Created.
- setCookie("Week7",
"Week 7 Cookie Path Test", expdate, "/coin70/week7");
- The Cookie "Week7" is
created with the Value "Week 7 Cookie
Path Test"
- Here we are
setting the path to /coin70/week7. This means that directories
beneath /coin70/week7 have the capability to read this Cookie.
Any directory not within week7 will not have access to this
particular cookie.
/coin70/week1
The "Cookie Dump" in /coin70/week 1
shows the two Cookies:
- TestPath=TestPath no path assigned;
- TestPath=TestPath /;
So when we do:
document.write("TestPath
= " + getCookie("TestPath")
+ "<BR>");
document.write("Week7
= " + getCookie("Week7")
+ "<BR>");
we get:
TestPath = TestPath no path assigned
Week7 = null
So what does all this mean? Remember, we created a Cookie in Week 1
"TestPath" with a Value "TestPath no path assigned"
and no path was assigned. When no path is assigned
the path will automatically be the current directory. getCookie("TestPath")
looks to see if there is a Cookie "TestPath" assigned to the
current directory. If there is a Cookie "TestPath" assigned to
that directory it then "grabs" that Cookie, if there isn't it
looks at its parent directory to see if there is a Cookie "TestPath"
assigned to that directory. This process is continued until the root is
reached.
getCookie("TestPath")
looks to see if there is a Cookie "TestPath" assigned to the
current directory -- YES -- Cookie "TestPath" with
Value the "TestPath no path assigned".
getCookie("Week7")
is not assigned to Cookie's current directory (/coin70/week1) or its
parent directory (/coin70) or even the root (/), so the value is null.
/coin70/week1/cookies
The "Cookie Dump" in /coin70/week1/cookies
shows the two Cookies:
- TestPath=TestPath no path assigned;
- TestPath=TestPath /;
So when we do:
document.write("TestPath
= " + getCookie("TestPath")
+ "<BR>");
document.write("Week7
= " + getCookie("Week7")
+ "<BR>");
we get:
TestPath = TestPath no path assigned
Week7 = null
getCookie("TestPath")
looks to see if there is a Cookie "TestPath" assigned to the
current directory (/coin70/week1/Cookies) -- NO. Next it
look at its parent directory (/coin70/week1) to see if there is a Cookie
"TestPath" assigned to that directory -- YES -- Cookie
"TestPath" with Value the "TestPath no path
assigned".
getCookie("Week7")
is not assigned to Cookie's current directory (/coin70/week1/Cookies) or
to its parent directory (/coin70/week1) or its parent-parent directory (/coin70)
or even the root (/), so the value is null.
/coin70/week2
The "Cookie Dump" in /coin70/week 2
shows the two Cookies:
- TestPath=TestPath Week 2;
- TestPath=TestPath /;
So when we do:
document.write("TestPath
= " + getCookie("TestPath")
+ "<BR>");
document.write("Week7
= " + getCookie("Week7")
+ "<BR>");
we get:
TestPath = TestPath Week 2
Week7 = null
getCookie("TestPath")
looks to see if there is a Cookie "TestPath" assigned to the
current directory (/coin70/week2) -- YES -- Cookie "TestPath"
with Value the "TestPath Week 2".
getCookie("Week7")
is not assigned to Cookie's current directory (/coin70/week2) or to its
parent directory (/coin70) or even the root (/), so the value is null.
/coin70/week7
The "Cookie Dump" in /coin70/week 7
shows the two Cookies:
- TestPath=TestPath /;
- Week7=Week 7 Cookie Path Test;
So when we do:
document.write("TestPath
= " + getCookie("TestPath")
+ "<BR>");
document.write("Week7
= " + getCookie("Week7")
+ "<BR>");
we get:
TestPath = TestPath /
Week7 = Week 7 Cookie Path Test
getCookie("TestPath")
looks to see if there is a Cookie "TestPath" assigned to the
current directory (/coin70/week7) -- NO. Next it look at
its parent directory (/coin70) to see if there is a Cookie "TestPath"
assigned to that directory -- NO. Next it looks at
root directory (/) to see if there is a Cookie "TestPath"
assigned to that directory -- YES -- Cookie "TestPath"
with Value the "TestPath /".
getCookie("Week7")
looks to see if there is a Cookie "Week7" assigned to the
current directory (/coin70/week7) -- YES -- Cookie
"Week7" with Value the "Week 7 Cookie Path
Test". |