here is a function that sets a cookie:
public void addCookie(String cookieName, String cookieValue, Integer maxAge, HttpServletResponse response) {
Cookie cookie = new Cookie(cookieName, cookieValue);
cookie.setPath("/mycampaigns");
cookie.setSecure(isSecureCookie);
cookie.setMaxAge(maxAge);
response.addCookie(cookie);
}
I believe in servlet 3.0, there is a way to do this directly. Unfortunately my organization uses 2.5 and UPGRADING at this juncture IS NOT AN OPTION.
is there way to use the response to set the cookie? Here's an example i found online
response.setHeader("SET-COOKIE", "[SOME STUFF]" +"; HttpOnly")
If this is the only way to do what i want, what would i replace "[SOME STUFF]" with so that i don't lose any of the data that my function currently stores in the cookie?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…