@Test
  public void testUserCanModifyTheirOwnCookie() throws Exception {
    Callback c = (request, response) -> {
      Cookie userCookie = findUserCookie(request.getCookies());
      if (userCookie == null) {
        userCookie = new Cookie("myCookie", "0");
      } else {
        userCookie =
            new Cookie("myCookie", Integer.toString(Integer.parseInt(userCookie.getValue()) + 1));
      }

      response.addCookie(userCookie);
      request.getSession().setAttribute("dummy", "value");
    };

    tester.setAttribute("callback_1", c);
    String url = tester.createConnector(true);
    tester.start();

    WebConversation wc = new WebConversation();
    WebRequest req = new GetMethodWebRequest(url + "/test/hello");
    req.setHeaderField("Cookie", "myCookie=" + 5);

    final WebResponse webResponse = wc.getResponse(req);
    assertEquals("6", webResponse.getNewCookieValue("myCookie"));
  }
Test that a servlet can modify cookies
extensions/geode-modules-session/src/integrationTest/java/org/apache/geode/modules/session/internal/filter/SessionReplicationIntegrationJUnitTest.java