0👍
You just need to create cookie with "localhost" without port to share it between localhost:8080 and localhost:8081, example:
public static void createWithHttpOnly(HttpServletResponse httpServletResponse, String token) {
javax.servlet.http.Cookie.Cookie cookie = new Cookie("my-http-only-cookie", token);
cookie.setSecure(true);
cookie.setHttpOnly(true);
cookie.setMaxAge(-1);
cookie.setDomain("localhost");
cookie.setPath("/");
httpServletResponse.addCookie(cookie);
}
Source:stackexchange.com