}     if (env.getIni("session.use_trans_sid").toBoolean() && ! env.getIni("session.use_only_cookies").toBoolean()) {  if (sessionId != null) { } else { if (sessionIdValue != null) sessionId = sessionIdValue.toString();  if (sessionId == null || "".equals(sessionId)) { String queryString = env.getRequest().getQueryString(); if (queryString != null) { String [] queryElements = queryString.split("&");  for (String queryElement : queryElements) { String [] nameValue = queryElement.split("=");  if (nameValue.length == 2 && nameValue[0].equals(cookieName)) sessionId = nameValue[1]; } } }  if (sessionId == null || "".equals(sessionId)) { sessionId = env.generateSessionId(); create = true; } }  env.addConstant("SID", new StringValueImpl(cookieName + '=' + sessionId), false);  OutputModule.pushUrlRewriter(env);
  public static boolean session_start(Env env)  {    if (env.getSession() != null) {      env.notice(L.l("session has already been started"));      return true;    }    SessionCallback callback = env.getSessionCallback();    Value sessionIdValue = (Value) env.getSpecialValue("caucho.session_id");    String sessionId = null;    final HttpServletResponse response = env.getResponse();    env.removeConstant("SID");    String cookieName = env.getIni("session.name").toString();    boolean generateCookie = true;    boolean create = false;    if (callback != null)      callback.open(env, WorkDir.getLocalWorkDir().getPath(), cookieName);    if (env.getIni("session.use_trans_sid").toBoolean()) {      //      // Use URL rewriting to transmit session id      //       if (sessionIdValue != null)        sessionId = sessionIdValue.toString();      if (sessionId == null || "".equals(sessionId)) {        String queryString = env.getRequest().getQueryString();        if (queryString != null) {          String [] queryElements = queryString.split("&");          for (String queryElement : queryElements) {            String [] nameValue = queryElement.split("=");            if (nameValue.length == 2 && nameValue[0].equals(cookieName))              sessionId = nameValue[1];          }        }      }      if (sessionId == null || "".equals(sessionId)) {        sessionId = env.generateSessionId();        create = true;      }      env.addConstant("SID", new StringValueImpl(cookieName + '=' + sessionId),                      false);      OutputModule.pushUrlRewriter(env);    } else {      //      // Use cookies to transmit session id      //       if (sessionIdValue != null)        sessionId = sessionIdValue.toString();      if (sessionId == null || "".equals(sessionId)) {        Cookie []cookies = env.getRequest().getCookies();        for (int i = 0; cookies != null && i < cookies.length; i++) {          if (cookies[i].getName().equals(cookieName) &&              ! "".equals(cookies[i].getValue())) {            sessionId = cookies[i].getValue();            generateCookie = false;          }        }      }      if (! generateCookie)        env.addConstant("SID", StringValue.EMPTY, false);      else if (sessionId == null || "".equals(sessionId)) {        sessionId = env.generateSessionId();        create = true;      }    }    if (response.isCommitted())      env.warning(L.l("cannot send session cache limiter headers because response is committed"));    else {      Value cacheLimiterValue = env.getIni("session.cache_limiter");      String cacheLimiter = String.valueOf(cacheLimiterValue);      Value cacheExpireValue = (LongValue)env.getSpecialValue("cache_expire");      if (cacheExpireValue == null)        cacheExpireValue = env.getIni("session.cache_expire");      int cacheExpire = cacheExpireValue.toInt() * 60;      if ("nocache".equals(cacheLimiter)) {        response.setHeader("Expires", "Thu, 19 Nov 1981 08:52:00 GMT");        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");        response.setHeader("Pragma", "no-cache");      }      else if ("private".equals(cacheLimiter)) {        response.setHeader("Cache-Control", "private, max-age=" + cacheExpire + ", pre-check=" + cacheExpire);      }      else if ("private_no_expire".equals(cacheLimiter)) {        response.setHeader("Cache-Control", "private, max-age=" + cacheExpire + ", pre-check=" + cacheExpire);      }      else if ("public".equals(cacheLimiter)) {        response.setHeader("Cache-Control", "max-age=" + cacheExpire + ", pre-check=" + cacheExpire);      }    }    SessionArrayValue session = env.createSession(sessionId, create);    sessionId = session.getId();    if (! env.getIni("session.use_trans_sid").toBoolean() && generateCookie) {      env.addConstant("SID",           new StringValueImpl(cookieName + '=' + sessionId),           false);      Cookie cookie = new Cookie(cookieName, sessionId);      cookie.setVersion(1);      if (response.isCommitted()) {        env.warning(L.l("cannot send session cookie because response is committed"));      }      else {        Value path = env.getIni("session.cookie_path");        cookie.setPath(path.toString());        Value maxAge = env.getIni("session.cookie_lifetime");        if (maxAge.toInt() != 0)          cookie.setMaxAge(maxAge.toInt());        Value domain = env.getIni("session.cookie_domain");        cookie.setDomain(domain.toString());        Value secure = env.getIni("session.cookie_secure");        cookie.setSecure(secure.toBoolean());        response.addCookie(cookie);      }    }    env.setSpecialValue("caucho.session_id", new StringValueImpl(sessionId));    return true;  }