- @CookieValue Annotation 활용
@CookieValue(value = "visitCount", defaultValue = "0", required = true) String cookieValue- 쿠키 생성
Cookie visitCountCookie = new Cookie("visitCount", cookieValue);- 쿠키 유효기간 설정
visitCountCookie.setMaxAge(2 * 60 * 60 * 24 * 365); // 2years
// 2 2seconds
// 2 * 60 2minutes
// 2 * 60 * 60 2hours
// 2 * 60 * 60 * 24 2days
// -1 until browser is open- 현재 경로 이하에 모두 쿠키 적용
visitCountCookie.setPath("/");- 클라이언트에게 보낼 응답에 쿠키 포함
response.addCookie(visitCountCookie);