Cookies problem

S

Simon Wigzell

I have discovered that saved cookie only apply to pages loaded from the
directory in which they are set. That is, if you set a cookie from a page in
your website domain root directory then load a webpage from a directory
below the root then that page will not understand the cookie. And vice
versa - if you set a cookie in a webpage in a sub directory of the root then
it won't be understoon by pages in the root. This is in IE anyway, I have
not tried other browsers.

This is a real pain! The way my website works, I have dynamic asp pages run
from the domain root directory and static html pages run from sub
directories. In this particular case I am allowing the user to set a cookie
determining the language to use, English, German or French and I find that
my pages in the sub directories are not getting the current language value.

Any ideas?
 
E

Evertjan.

Simon Wigzell wrote on 07 apr 2007 in comp.lang.javascript:
I have discovered that saved cookie only apply to pages loaded from
the directory in which they are set. That is, if you set a cookie from
a page in your website domain root directory then load a webpage from
a directory below the root then that page will not understand the
cookie. And vice versa - if you set a cookie in a webpage in a sub
directory of the root then it won't be understoon by pages in the
root. This is in IE anyway, I have not tried other browsers.

You are wrong.

Pages from directories "below the root" do not belong to the website,
so they normally cannot even be requested on the web.

Other subdirectory files can read the cookies having the root path '/'.
Perhaps you did not or did wrongly set the cookie path?

<http://www.quirksmode.org/js/cookies.html> says:
"Usually the path is set to /, which means the cookie is valid throughout
the entire domain."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,068
Latest member
MakersCBDIngredients

Latest Threads

Top