Snippets Collections
public static String getHttpOnlyCookieHeader(Cookie cookie) {

    NewCookie newCookie = new NewCookie(cookie.getName(), cookie.getValue(), 
            cookie.getPath(), cookie.getDomain(), cookie.getVersion(), 
            cookie.getComment(), cookie.getMaxAge(), cookie.getSecure());

    return newCookie + "; HttpOnly";

And the usage:

response.setHeader("SET-COOKIE", getHttpOnlyCookieHeader(myOriginalCookie));

a bit late but since 2.0, has a constructor with httpOnly, you do not need to append it to toString() : NewCookie nc = new NewCookie("name","value","path","domain","comment",3600,true, true);

Fri Jan 29 2021 16:39:09 GMT+0000 (UTC)

#java #httponly #coockie #jax-rs

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension