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
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.