Skip to content

Instantly share code, notes, and snippets.

@jafetsanchez
Last active May 15, 2020 19:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jafetsanchez/cc1747d6ad0ccb85cbec32e72da650a6 to your computer and use it in GitHub Desktop.
Save jafetsanchez/cc1747d6ad0ccb85cbec32e72da650a6 to your computer and use it in GitHub Desktop.
public void createJwtCookie(String jwtToken, HttpServletResponse response)
{
Cookie cookie = new Cookie("MIGALLETITA", jwtToken);
//MUST have option
cookie.setHttpOnly(true);
/*Expiration is in 1 week*/
cookie.setMaxAge(7 * 24 * 60 * 60);
cookie.setPath("/");
//Add the cookie to the response
response.addCookie(cookie);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment