Cookie question

by "Steve Mount" <steve(at)saltyrain.com>

 Date:  Thu, 20 Jun 2002 14:07:47 -0400
 To:  <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
OK, I have two pages in different paths that have same-named cookies.  When
I set these cookies via the HTTP headers, I use the path= attribute to keep
them separate, and that worked fine until I named the directories "test" and
"test2".  Like this:

Set-Cookie: name=Steve; path=/test;
Set-Cookie: name=Joe; path=/test2;

The problem is that pages in /test2 see both cookies ... the JavaScript
document.cookie property is "name=Joe; name=Steve" which explains why those
pages think the name is Steve, and not Joe.  The problem is that the spec
for cookies says that the cookie gets sent to the page if the page contains
the path, and "/test" is in "/test2".

Anyone else have experience with this?  I'm thinking of adding a trailing /
to the path names:

Set-Cookie: name=Steve; path=/test/;
Set-Cookie: name=Joe; path=/test2/;

Any thoughts about that?  It seems to work, but I don't want to break any
browsers.

-------------------------------------------------------------
Steve Mount, Software Engineer            steve(at)saltyrain.com
Home Site                            http://www.saltyrain.com
US Constitution Online          http://www.usconstitution.net

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.