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 Servlets and the fly likes cookie question 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 » Java » Servlets
Bookmark "cookie question" Watch "cookie question" New topic

cookie question

Stan dmello

Joined: Jul 03, 2005
Posts: 1

I was wondering if we can set the cookie for the domain other than our own domain.

I mean, if our domain is then can we use setDomain("")
to set cookie for


Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703

Some searching from google reveals the answer:

"Normally, the browser returns cookies only to the same hostname that sent them. You can use setDomain method to instruct the browser to return them to other hosts within the same domain. To prevent servers from setting cookies that apply to hosts outside their domain, the specified domain must meet the following two requirements: It must start with a dot (e.g.,; it must contain two dots for noncountry domains like .com, .edu, and .gov; and it must contain three dots for country domains like and"

My Blog: Down Home Country Coding with Scott Selikoff
Consider Paul's rocket mass heater.
subject: cookie question
Similar Threads
Cookies across multiple domains
Cookies access between sub domains
Apache Web Server mapping of URL to index page of the Application
Using spring security across multiple apps
Multiple JSESSIONID cookies getting created