tags:

views:

168

answers:

1

Cookies are store under domain-name. For example, a cookie that generated by sub1.xxx.com/login.jsp can be stored in sub1.xxx.com, or xxx.com.

Now I am wondering if we can store the cookie in sub2.xxx.com?

+1  A: 

Give the cookie a domain name of .xxx.com (note the leading dot). This way the cookie is accessible by any subdomain. If you intend to share the HttpSession among subdomains, then you can also just configure the appserver to do so. Best is to refer its documentation for details. In case of for example Tomcat, just set the emptySessionPath attribute of the <Connector> to true:

<Connector emptySessionPath="true">
BalusC