JBoss session cookies

If you are using cookies for inter-context communication you will notice after migrating from JBoss 4 to 5 that they just don’t work.

If you take the time to do some cookie debuging you will notice that in JBoss 5 the cookies are bound to the context as shown bellow:

Value ACF23793236E94A664E652AA77AC7578
Host localhost
Path /myApp/
Secure No
Expires At End Of Session

This means there is no way this cookie can be used to comunicate with /myApp2/ for instance.

The solution, as found in this track consists to modify ${JBOSS_HOME}/server/default/deploy/jbossweb.sar/context.xml and add the following line which will force the cookies to be bound to / thus beeing shared between /myapp/ and /myapp2/

<SessionCookie path="/"/>

Leave a Reply