This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes getDomain of Cookie ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "getDomain of Cookie ??" Watch "getDomain of Cookie ??" New topic
Author

getDomain of Cookie ??

R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
Hi
I am slightly confuse after reading API doc and Core book regarding getDomain() of Cookie.
API says:
======
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).
======
Core book says
=======
the domain specified is required to start with a dot (e.g.,
.prenhall.com), and must contain two dots for noncountry domains
like .com, .edu and .gov; and three dots for country domains like
.co.uk and .edu.es. For instance, cookies sent from a servlet at
bali.vacations.com would not normally get sent by the browser to
pages at mexico.vacations.com. If the site wanted this to happen,
the servlets could specify cookie.setDomain(".vacations.com").

=======
Now my doubt is as per API ".serverName.com" will not send cookie to "subDomain.serverName.com" BUT as per Core book if Domainis set to ".vacations.com" then cookie can be send to "mexico.vacations.com" and also to "bali.vacations.com"
Please clear my doubt.
TIA


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Kevin Mukhar
Ranch Hand

Joined: Nov 28, 2000
Posts: 83
The two are correct and are saying the same thing.
"API says:
======
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).
======"
This means that a cookie with a domain of .foo.com will be sent to any server at www.foo.com, or www3.foo.com, or mexico.foo.com or bali.foo.com or any server where there is a SINGLE subdomain preceding foo.com. The cookie is not sent to a.b.foo.com because there are TWO subdomains preceding foo.
In other words, cookies for the foo.com zone will be sent to the server bali because it is in that zone. However, cookies for the foo.com zone will NOT be sent to the server a because it is the b.foo.com zone.
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
THanks a lot Kevin ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getDomain of Cookie ??
 
Similar Threads
setDomain() on Cookie
cookie setDomain problem.
Cookie persistance across packages?
Doubt in Cookies
cookie question