Skip to main content

default cookie domain of jsession id cookie

2 replies [Last post]
cambazz
Offline
Joined: 2008-06-04
Points: 0

Hello,

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

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

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

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

from web.xml

30

Reply viewing options

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

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'
'http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd'>




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 javax.security.SessionCookieConfig. :)

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

public void contextInitialized(ServletContextEvent sce) {
sce.getServletContext().getSessionCookieConfig().setDomain(
".mysite.com");
}

You can try this on the latest GlassFish v3.

Let us know if you have any questions.

Thanks!

Jan

> [Message sent by forum member 'onlyplastik' (onlyplastik)]
>
> http://forums.java.net/jive/thread.jspa?messageID=344378
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net