The solution to your problem is twofold: you are replacing the session, probably best done through
getSession().invalidateNow();
and sends a redirect to the bookmark url. This can also be done with setResponsePage :
setResponsePage(OtherPage.class, new PageParameters().add("foo", "bar"));
This will send a 302 redirect to the browser with the bookmark URL and provide parameters, which will give the servlet container the ability to reset the session (basically log out), waiting for the browser to respond. It also initiates a new session cookie (since the previous session is no longer active).
source share