• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Cookies issue with IE - need help!

JonTheBaller

Golden Member
I'm using JavaScript to set a cookie. When I set the path attribute of the cookie to "/", everything works fine. However, I want to limit access to the cookie to the page that created it. Thus, I want to be able to set the path attribute to location.pathname (for example /home/src/accounts.html). I can set cookies fine in IE and Mozilla, but only Mozilla is able to get the cookie. IE can't match the cookie path for some reason. Any ideas? Your help is greatly appreciated!
 
A cookie path should represent a directory, not an individual file. From MSDN:

In a similar manner to domains, the path attribute of a cookie restricts a cookie's visibility to a particular part of a web-server's directory tree. A web page such as http://www.microsoft.com/jscript might have a cookie with path '/jscript', which is only relevant to the JScript pages of that site. If a second cookie with the same name and domain also exists, but with the path '' (equivalent to '/'), then the web page would only see the first cookie, because its path is a closer match to the URL's path.

Paths represent directories, not individual files, so '/usr/local/tmp' is correct, but '/usr/local/tmp/myfile.htm' isn't. Forward slashes ('/' not '\') should be used. Trailing slashes as in '/usr/local/tmp/' should be avoided. That is why the top-level path is '' (a zero-length string), not '/'.
 
Back
Top