I am using tomcat 7.0 and java 6. I want to share session between domains and subdomain for examples.com and abc.examples.com
so in context.xml put tag
<Context antiResourceLocking="false" privileged="true" sessionCookieDomain=".examples.com" sessionCookiePath="/" >
successfully share Cookies JSESSIONID but when i set attribute in examples.com
logger.info( "Demo1 : "+httpSession.getId());
httpSession.setAttribute("data", "subhash lamba");
logger.info(" Demo1 data"+ httpSession.getAttribute("data") );
that can not be accessible in test.examples.com subdomain
HttpSession httpSession=request.getSession();
logger.info( "Demo3 : "+httpSession.getId());
logger.info(" Demo3 data "+ httpSession.getAttribute("data") );
when i log JSESSIONID in both domain and subdomain are same but when i try to share attribute between them it is not working.
I find solution my self. I successfully get sharing session between two domain and now just my problem was identify same user. When i try for sharing session data between those two domain and sub-domains at that time it's not work because server maintain session for individual application.
Now my solution is:
In Tomcat server there is context, In context we can store Object and same Context can be accessible by every application in same Tomcat. So Now I create on java.util.Map object in java.util.Map object store key-value pair in which key is JSESSIONID and value is user Id who login. So now i can access easily user who login in domain and all sub-domains.