From: Ben W. <bw...@jb...> - 2005-07-29 21:13:19
|
User: bwang Date: 05/07/29 17:12:09 Modified: src/main/org/jboss/web/tomcat/tc5/session JBossManager.java Log: Another fix for JBAS-2034 that added secure flag and context path. Revision Changes Path 1.11 +20 -3 jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossManager.java (In the diff below, changes in quantity of whitespace are not shown.) Index: JBossManager.java =================================================================== RCS file: /cvsroot/jboss/jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- JBossManager.java 8 Feb 2005 07:31:20 -0000 1.10 +++ JBossManager.java 29 Jul 2005 21:12:09 -0000 1.11 @@ -32,6 +32,8 @@ import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleListener; import org.apache.catalina.Session; +import org.apache.catalina.connector.Connector; +import org.apache.catalina.connector.Response; import org.apache.catalina.util.LifecycleSupport; /** @@ -39,7 +41,7 @@ * session operations, e.g., add, remove, etc. * * @author Ben Wang - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ */ public abstract class JBossManager implements AbstractJBossManager, Lifecycle, @@ -228,6 +230,7 @@ if (response != null) { Context context = (Context) container_; + Connector connector = ((Response)response).getConnector(); if (context.getCookies()) { // set a new session cookie @@ -236,8 +239,22 @@ { log_.debug("Setting cookie with session id:" + sessionId + " & name:" + Globals.SESSION_COOKIE_NAME); } - newCookie.setMaxAge(-1); - newCookie.setPath(context.getPath()); + + String contextPath = null; + if (!connector.getEmptySessionPath() && (context != null)) { + contextPath = context.getEncodedPath(); + } + + if ((contextPath != null) && (contextPath.length() > 0)) { + newCookie.setPath(contextPath); + } else { + newCookie.setPath("/"); + } + + if (connector.getSecure()) { + newCookie.setSecure(true); + } + response.addCookie(newCookie); } } |