• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setDomain doesn't let me set cookie

 
lint
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty new to servlets and cookies in general, but I've had no problem setting cookies so far. I have a need to use the setDomain method in order to specify a different domain from which a cookie can be retrieve. Whenever I try cookie.setDomain(".foo.com"); I find that a cookie will not get set. (I usually open up the list of cookies in IE to take a look at what is being set.) Omitting this line with identical code works. Can anybody suggest what I might need to do to make this work? Better yet, a real working example would be great. Thanks!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you set a cookie for the domain ".foo.com" address the machine as its fully qualified domain name ("www.foo.com"?). The browser will only set cookies that come from the domain they are set for.
Example:
1) You hit .bar.com and want to set a cookie for foo.com. The browser will just reject it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic