Skip to content

Instantly share code, notes, and snippets.

@codinko
Created December 26, 2015 00:08
Show Gist options
  • Save codinko/cf17dacbe29bd1de0dda to your computer and use it in GitHub Desktop.
Save codinko/cf17dacbe29bd1de0dda to your computer and use it in GitHub Desktop.
ServletResponseSetCookieSnippet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Cookie cookie = new Cookie("username", "harley");
cookie.setMaxAge(60*60*24); // 24 hours for expiry
response.addCookie(cookie);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment