Placing Cookies in the Response Headers

The cookie is added to the Set-Cookie response header by means of the addCookie method of HttpServletResponse. Here’s an example:

  Cookie userCookie = new Cookie("user", "uid1234");
  response.addCookie(userCookie);

Leave a Reply