diff --git a/src/main/java/com/mpnp/baechelin/util/CookieUtil.java b/src/main/java/com/mpnp/baechelin/util/CookieUtil.java index 46e5f6c..9a5191b 100644 --- a/src/main/java/com/mpnp/baechelin/util/CookieUtil.java +++ b/src/main/java/com/mpnp/baechelin/util/CookieUtil.java @@ -28,24 +28,24 @@ public static Optional getCookie(HttpServletRequest request, String name // 쿠키 생성 public static void addCookie(HttpServletResponse response, String name, String value, int maxAge) { -// ResponseCookie cookie = ResponseCookie.from(name, value) -// .domain(".bae-chelin.com") -// .path("/") -// .httpOnly(true) -// .maxAge(maxAge) -// .secure(true) -// .sameSite("None") -// .build(); -// -// response.addHeader("Set-Cookie", cookie.toString()); - Cookie cookie = new Cookie(name, value); - - cookie.setPath("/"); - cookie.setHttpOnly(true); // XSS 공격을 막기 위한 설정 - cookie.setMaxAge(maxAge); - cookie.setDomain(".bae-chelin.com"); + ResponseCookie cookie = ResponseCookie.from(name, value) + .domain(".bae-chelin.com") + .path("/") + .httpOnly(true) + .maxAge(maxAge) + .secure(true) + .sameSite("None") + .build(); - response.addCookie(cookie); + response.addHeader("Set-Cookie", cookie.toString()); +// Cookie cookie = new Cookie(name, value); +// +// cookie.setPath("/"); +// cookie.setHttpOnly(true); // XSS 공격을 막기 위한 설정 +// cookie.setMaxAge(maxAge); +// cookie.setDomain(".bae-chelin.com"); +// +// response.addCookie(cookie); } // 쿠키 삭제 @@ -58,8 +58,6 @@ public static void deleteCookie(HttpServletRequest request, HttpServletResponse cookie.setValue(""); cookie.setPath("/"); cookie.setMaxAge(0); - cookie.setSecure(false); - cookie.setDomain(""); response.addCookie(cookie); }