URI Fragments are not handled properly by encodeUrl. See test below.
Using UriComponentsBuilder in encodeUrl fixes this issue.
@Test
public void encodeUrlWithFragment() {
assertThat(new CookieHttpSessionStrategy().encodeURL("/url?a=b#xyz", "2"))
.isEqualTo("/url?a=b&_s=2#xyz");
}}