I have read apache tomcat documentation a day before, and I am so confused about emptySessionPath
. Up to my knowledge, if it's set to true, the emptySessionPath
is stored at the root folder of web application. Please give the right definition of the term emptySessionPath
and what happens if it is set to true and false?
Please guide me.Thanks in advance.
If emptySessionPath is set to true, it will eliminate the context path from JSESSIONID cookie.It will set a cookie path to /.This attribute can be used for cross application autehentication mechanism.
Just in case, for the web_app version 3.0, the cookie configuration is standarized, so the equivalent to the AJP's emptySessionPath in webapp 3.0 is:
<session-config>
<cookie-config>
<path>/</path>
<secure>true</secure>
</cookie-config>
</session-config>
The
emptySessionPath
field just states whether the all cookie should be stored in the root URL path/
(ifemptySessionPath=true
) or not (otherwise).This is used by Apache's Connector. See details here (This is for AJP Connector, which is part of the Connnector object).
What this basically means is:
JSESSIONID
is the ID Session for your Webapp. See a full explanation here.Update: This information about usage is somewhat outdated - see here for a more up-to-date information on how to set the Session path also for recent tomcat.
Session are, as you probably know, often maintained by a cookie. A cookie has two values that determines whether they should be returned by the browser for a certain request, cookieDomain and cookiePath. The cookiePath must match that of the request.
A request is made for
Cookie would be returned with cookie path:
But not for cookie path:
By spec, a session is not shared between different web applications, so if you have web application
foo.war
deployed under/foo
, the session cookie path would, by default be set to/foo
.It seems Connector.emptySessionPath is a protected variable on Connector. I haven't read the code - but I guess it has something to do with Tomcat's single sign on or sharing sessions, where you login to one context and are authenticated in all - in which case the cookie path must be
/
for the session cookies.