Cookies are stored under a domain-name.
For example, a cookie that’s generated by sub1.example.com/login.jsp can be stored in sub1.example.com, or example.com.
Can I store the cookie in sub2.example.com?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Give the cookie a domain name of
.example.com(note the leading dot). This way the cookie is accessible by any subdomain. If you intend to share theHttpSessionamong 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 theemptySessionPathattribute of the<Connector>totrue: