@Test
  public void testSessionRemains1() throws Exception {
    Callback c = (request, response) -> {
      String output;
      HttpSession session = request.getSession();
      if (session.isNew()) {
        output = "new";
        session.setAttribute("foo", output);
      } else {
        output = (String) session.getAttribute("foo");
        if (output != null) {
          output = "old";
        }
      }
      PrintWriter out = response.getWriter();
      out.write(output);
    };

    tester.setAttribute("callback_1", c);
    tester.start();

    request.setMethod("GET");
    request.setURI("/test/hello");
    request.setHeader("Host", "tester");
    request.setVersion("HTTP/1.0");

    response = HttpTester.parseResponse(tester.getResponses(request.generate()));

    assertEquals("Session should be new", "new", response.getContent());

    List<Cookie> cookies = getCookies(response);
    request.setHeader("Cookie", "JSESSIONID=" + getSessionCookie(cookies).getValue());

    response = HttpTester.parseResponse(tester.getResponses(request.generate()));

    assertEquals("Session should be old", "old", response.getContent());

    List<Cookie> cookies2 = getCookies(response);
    assertEquals("Session IDs should be the same", getSessionCookie(cookies).getValue(),
        getSessionCookie(cookies2).getValue());

    Region r = getRegion();
    assertNotNull("Session object should exist in region",
        r.get(getSessionCookie(cookies).getValue()));
  }
Test that getSession(false) does not create a new session
extensions/geode-modules-session/src/integrationTest/java/org/apache/geode/modules/session/internal/filter/SessionReplicationIntegrationJUnitTest.java