tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sanket Paranjape <>
Subject Session Replication across common base domain
Date Fri, 03 Jan 2014 09:01:44 GMT

I am using Tomcat 7.0.47 on windows 7 with JDK 1.7.

I want to achieve session replications on multiple subdomains. If I have 
a domain as and, then I would like to 
store session cookie on "" and hence then I would be able to 
access same session on both domains. By default session cookie is set on 
whole domain, if I access then session cookie will be 
set on this domain.

I went through the documentation for Tomcat 7 and found that in 
<Context> element type I can add attribute like "sessionCookieDomain". I 
can easily set this attribute to base domain like "" and 
this works like charm.

But my requirement is slightly different. I have single tomcat serving 
multiple domains. They all different base domains as well. So hardcoding 
would not help me out here.

So I tried following.

In docs I found this link, It says 
that className attribute can be set for context.
So I wrote my own class MyStandardContext which extends 
org.apache.catalina.core.StandardContext. I overridden public String 
getSessionCookieDomain() method. I want to return base domain of the URL 
from this domain so that tomcat will set cookie on this domain. But to 
my surprise I do not have access to Request URI. If I could get access 
to this URI somehow then I would be able to extract base domain. It is 
not possible. is it?

I also tried adding multiple hosts in conf/server.xml under <Engine>. 
This loads context multiple times, which I do not wish.

My question is there any way I can get access to request URI in 
MyStandardContext? Or is there any configuration which forces tomcat to 
set cookie on base domain instead full domain?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message