You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2010/06/19 12:03:19 UTC

svn commit: r956210 - /tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java

Author: rjung
Date: Sat Jun 19 10:03:18 2010
New Revision: 956210

URL: http://svn.apache.org/viewvc?rev=956210&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48379

Make session cookie name, domain and path configurable
per context.

Backport of r953025 from TC6.

Caution: this change makes OACC incompatible with
TC 6 prior to 6.0.27.

Modified:
    tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java

Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java?rev=956210&r1=956209&r2=956210&view=diff
==============================================================================
--- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java (original)
+++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java Sat Jun 19 10:03:18 2010
@@ -459,25 +459,40 @@ public class JvmRouteBinderValve extends
             Context context = request.getContext();
             if (context.getCookies()) {
                 // set a new session cookie
-                Cookie newCookie = new Cookie(Globals.SESSION_COOKIE_NAME,
-                        sessionId);
+                String scName = context.getSessionCookieName();
+                if (scName == null) {
+                    scName = Globals.SESSION_COOKIE_NAME;
+                }
+                Cookie newCookie = new Cookie(scName, sessionId);
+                
                 newCookie.setMaxAge(-1);
+                
                 String contextPath = null;
-                if (!response.getConnector().getEmptySessionPath()
-                        && (context != null)) {
-                    contextPath = context.getEncodedPath();
+                if (!response.getConnector().getEmptySessionPath() &&
+                        (context != null)) {
+                    if (context.getSessionCookiePath() != null) {
+                        contextPath = context.getSessionCookiePath();
+                    } else {
+                        contextPath = context.getEncodedPath();
+                    }
                 }
                 if ((contextPath != null) && (contextPath.length() > 0)) {
                     newCookie.setPath(contextPath);
                 } else {
                     newCookie.setPath("/");
                 }
+                
+                if (context.getSessionCookieDomain() != null) {
+                    newCookie.setDomain(context.getSessionCookieDomain());
+                }
+
                 if (request.isSecure()) {
                     newCookie.setSecure(true);
                 }
+
                 if (log.isDebugEnabled()) {
                     Object[] args = new Object[] {sessionId,
-                            Globals.SESSION_COOKIE_NAME,
+                            newCookie.getName(),
                             newCookie.getPath(),
                             new Boolean(newCookie.getSecure()),
                             new Boolean(context.getUseHttpOnly())};



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org