Archive of UserLand's first discussion group, started October 5, 1998.

Re: Tricky problem!

Author:Scott Storkel
Posted:11/23/1998; 5:00:07 PM
Topic:First message
Msg #:418 (In response to 415)
Prev/Next:417 / 419

When you send a cookie to a browser, you give it a domain name and a path. When determining whether to send the cookie to the server with a particular HTTP request, the browser looks at the domain and, perhaps, the path.

If your cookie is associated with foo.bar.baz.com, the browser will send it to the server whenever you make a request for data from foo.bar.baz.com or a sub-domain (e.g. dave.foo.bar.baz.com). The more generic the domain specified in your cookie, the more widely the cookie will apply. In this case, you may have specified "nirvana.userland.com" when what you really wanted is ".userland.com" (note the extra period!). If you don't specify a domain name when creating a cookie, the browser uses the domain name of the server which sent the cookie!

If the domains match, the browser then looks at the path data associated with the cookie. The path can further be used to restrict the instances when the cookie is returned. For example, you might set the path to "/discussions/cookies". If you then make a request for "/index.html" the cookie won't be returned. Similarly, if you request "/discussions/data.html" you won't get the cookie. If you request "/discussions/cookiesToMake.html" or "/discussions/cookies/index.html" the cookie WILL be returned. The most generic path is "/".

More information can be found on developer.netscape.com. Try this URL for starters:

http://developer1.netscape.com/docs/manuals/communicator/jsguide4/cookies.htm




This page was archived on 6/13/2001; 4:45:53 PM.

© Copyright 1998-2001 UserLand Software, Inc.