tags:

views:

892

answers:

2

Hi,

We need to change the session ID length gerenated by tomcat. By default it is 32 bytes, unfortunatly we need a session ID length of 20. Looking online I can see the StandardManager seems to manage this which extends PersistanceManager.

Does anyone know if the sessionIdLength can be modified in the tomcat config? If so what files?

An alternative would be to create a custom Manager which simply overrides/sets the sessionidLength. Is this possible? How do you tell tomcat to use the custom manager in the config?

Any help/comments are appreciated,

James

+2  A: 

Yes, you can modify the StandardManager via config file. The Manager element can be nested inside any Context.

So, modify whichever config file has your Context. It might be the server.xml located in the conf directory. Or a context.xml located in the META-INF directory of your war file.

To provide a default for the entire server, edit your $CATALINA_HOME/conf/context.xml. Uncomment the Manager line, and add the sessionIdLength attribute.

<Manager sessionIdLength="10" />
Steve K
Thanks for the response,I added the above line to my /conf/context.xml with no effect. I am not sure if this is an issue but I also have <Resource> and <Realm> tags in the contect.xml.
James
I had to delete my JSESSIONID cookie, then restart Tomcat to get a shorter cookie. Tomcat by default will persist Session information to disk during a restart. So I think it was persisting the longer cookie, and loading it back on startup. So, try to delete you JSESSIONID cookie, restart Tomcat. Hopefully that will result in the desired result.
Steve K
A: 

Add the sessionIdLength attribute to the element of your Tomcat's context.xml (or wherever you're manager is defined).

Incidentally, the docs say that the default is 16, not 32.

skaffman

related questions