PDA

View Full Version : Cookies ... aaAARRGGHH!


Mr J
09-22-2002, 12:29 PM
I am trying to get a better understanding of Cookies.

:confused:

I have no problem setting, getting, or deleting Cookies, my problem is understanding the placement of files containing Cookies.

:confused:

Example:

Two files in the same folder containing the same Cookie script.
The only difference between the two is the Cookie name.
Lets say "Cookie1" and "Cookie2".

On loading both pages both Cookies are set, yet only one page retrieves its data.

I open the cookie document and see that both Cookies have been written but still only one retrieval.

:confused: :confused: :confused:

Below are the results of some tests I carried out .... total mayhem.

If you read the following and understand it explain it to me

:(



One Folder.

Cookie name (CookieNo1) same in page1.htm and page2.htm both files in same folder.
One cookie doc created, both files functioned as one

Cookie name different in page1.htm and page2.htm both files in same folder.
Page1 set first.
After setting page1 cookie (CookieNo1) with data "COOK NUMBER ONE", page1 returned correct data, then called cookie from page2 and got "CookieNo"
Set cookie in page2 (CookTWO) with data "once upon a time", retrieved data in page2 and got "1=COOK NUMBER ONE", page1 returned correct data.

Page2 set first.
Set page2 (CookTWO) with data "once upon a time", page2 returned correct data, then called cookie from page1 and got "CookTWO=on"
Set cookie in page1 (CookieNo1) with data "COOK NUMBER ONE", retrieved data in page1 and got "ce upon a time".
When CookTWO delete, page 1 retireved correct data.

Thought.
Only the first cookie to be set will retrieve correct data.
Only one cookie per folder.

Two Folders.

Cookie name same, in folder cook1/page1.htm (CookieNo1), in folder cook2/page2.htm (CookieNo1).


Set page1.htm (CookieNo1) with "first cookie", One cookie doc created, correct data retrieved, no data retrieved in page2.htm
Set page2.htm (CookNo1) with "two cookies", a second cookie doc created, correct data retrieved, page1 retrieved correct data.
Cookies with different names had same results.

Thought.
Cookie in separate root folders can have same name.

Subfolders.
Both cookies same name.


Page1.htm (CookieNo1) in folder cook1, Page2.htm (CookieNo1) in folder cook1/cook2
Set page1.htm with "cook one", retrieved correct data, called cookie in page2.htm and retrieved "C".
Set page2.htm with "cook two", page2.htm retrieved "c" page1.htm retrieved correct data.
Got same results if page 2 set before page1