Forums Register Login

setDomain() on Cookie

+Pie Number of slices to send: Send
hi folks!
i've a question. if i use setDomain() on the cookie tell
which one would be the correct answer.
Cookie c = new Cookie("test","testCookie");
c.setDomain(".foo.com");
options:
1. www.foo.com
2. a.b.foo.com
(this is from the Java Servlet API but i want to make sure that i understand it correctly)
my answer is (1). is that right? 'coz for the cookie to be visible to (2) we need
to have DNS as b.foo.com. am i right or missing something?
so this presicely means its only the domain which we specify to which the cookie is visible.
it is not visible to the internal servers as well. (in above example we have two servers,
one main server with www.foo.com and another subserver-like my.yahoo.com- a.b.foo.com).
please thro some light on this. also let me know any other important thing need to be keep in mind regarding this...
regards
maulin
+Pie Number of slices to send: Send
cookies set from one domain are visible to sub-domains, without needing to use setDomain().

https://coderanch.com/t/353843/Servlets/java/Cookies-across-multiple-domains

check Mike Fuellbrandt's'post, he is a colleague of mine.

We set a cookie for foo.com and it is visible to a.foo.com, b.foo.com, c.foo.com, etc...
+Pie Number of slices to send: Send
but not to a.b.c.foo.com right? thats what i get from API...
regards
maulin
+Pie Number of slices to send: Send
plz explain me the following excerpt from the API,
"The form of the domain name is specified by RFC 2109. A domain name begins with a dot (.foo.com) and means that the cookie is visible to servers in a specified Domain Name System (DNS) zone (for example, www.foo.com, but not a.b.foo.com). By default, cookies are only returned to the server that sent them."
doesnt it mean that if i set cookie domain to be ".foo.com" then it's not visible in "a.b.foo.com"?. the cookie will be visible in "www.foo.com".
well, practically it works for a.b.foo.com i guess (with an example i ran). so am i incorrect in interpreting the API or what?
please try to provide examples of the both cases,
1. the case in which it will work (i see the cookie),
2. the case in which i won't see the cookie.
(
i know that, if i am setting cookie from .a.com 's web server to be having domain ".c.com" then it won't be visible to any code of ".a.com" webserver...but what about ".a.com" and ".b.a.com" domains?
)
regards
maulin.
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3646 times.
Similar Threads
Question about url mapping and context
getDomain of Cookie ??
Cookie persistance across packages?
keeping the directory path hidden
cookie setDomain problem.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:16:17.