Tuesday, October 25, 2005

Suppose we have a XYZ site, where it sets the cookie with the name as "username" we have another site say ABC where it sets the cookie with the same name i.e. "username". Now when the cookies are collected in the array and when cookie.getName() checks for username, it can display the wrong name in the server. How does the server handles this problem.

The browser will send only those cookies that were set by this server with every request to the server. So, a cookie with name "username" set by javaranch will be sent to javaranch and a cookie with name "username" set by yahoo.com, will be sent to yahoo.com. A particular site can only retrieve the cookies that it set.

Cookie.setPath() method

The cookie.setPath(String uri) method sets the return path to where the cookie should come back along with the request from the browser.

If we do not set the return path, does the cookie comes back to the same server path?

If you do not call the setPath method on a cookie, the browser returns the cookie only to URLs in or below the directory containing the page that sent the cookie.


Also take a look at the article "Cross Domain Cookie Provider" Here

0 Comments:

Post a Comment

<< Home