Skip to main content

default cookie domain of jsession id cookie

2 replies [Last post]
Joined: 2008-06-04


I am trying to modify default cookie domain of the jsessionid cookie.

namely I have: and subdomains that are dynamic, such as I have done some urlrewriting and all the domains *
goes to the same ip.

it works nice, but while going into a new session is started, since the domain is different. thus I want to be able to set the domain of the cookie to

I have done the following, but no luck. (btw, I am on gf3 prelude)

from web.xml


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-11-02

I just spent all day trying to find an app-server-agnostic workaround for this. Failing that, I decided to re-investigate your cookieDomain idea. I got it working. It needed to be in sun-web.xml instead of web.xml. Here's my full file:

Application Server 9.0 Servlet 2.5//EN'

Message was edited by: onlyplastik

Jan Luehe

Yes, cookie-properties is defined only for sun-web.xml, not web.xml.

As for configuring the cookie domain in a portable fashion,
Servlet 3.0 is your friend, see :)

With Servlet 3.0, the following code (e.g., in a ServletContextListener)
is possible:

public void contextInitialized(ServletContextEvent sce) {

You can try this on the latest GlassFish v3.

Let us know if you have any questions.



> [Message sent by forum member 'onlyplastik' (onlyplastik)]
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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