Tomcat modifies the name of JSESSIONID in the cookie

Source: Internet
Author: User

1. tomcat5 modification method

Add the org. Apache. Catalina. session_cookie_name parameter to the startup Item.

Linux
Java_opts = '-dorg. Apache. Catalina. session_cookie_name = yousessionname'

Win
Set java_opts = "-dorg. Apache. Catalina. session_cookie_name = yousessionname"

2. Tomcat 6 and tomcat 7 are modified in the same way.

Add the sessioncookiename parameter to the context container label.

<Context Path = "/" docbase = "webapp" reloadable = "false" sessioncookiename = "yoursessionname"> </context>

3. Why is it so easy to use?

Added parameters for tomcat5 to take effect for all the context, which has a great impact. Therefore, it will only be set for context in later versions.

Tomcat5 source code is as follows:
Public final class globals
/**
* The Name Of The cookie used to pass the session identifier back
* And forth with the client.
*/
Public static final string session_cookie_name =
System. getproperty ("org. Apache. Catalina. session_cookie_name ",
"JSESSIONID ");

The source code of tomcat6 and tomcat7 is similar, as shown below:
Public class standardcontext
.... Omitted
/**
* The name to use for session cookies. <code> null </code> indicates that
* The name is controlled by the application.
*/
Private string sessioncookiename;
/**
* Gets the name to use for session cookies.
*
* @ Return the value of the default session cookie name or null if not
* Specified
*/
Public String getsessioncookiename (){
Return sessioncookiename;
}

/**
* Sets the name to use for session cookies. overrides any setting that
* May be specified by the application.
*
* @ Param sessioncookiename the name to use
*/
Public void setsessioncookiename (string sessioncookiename ){
String oldsessioncookiename = This. sessioncookiename;
This. sessioncookiename = sessioncookiename;
Support. firepropertychange ("sessioncookiename ",
Oldsessioncookiename, sessioncookiename );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.