Class CookieUtil

java.lang.Object
com.broadleafcommerce.auth.user.util.CookieUtil

public class CookieUtil extends Object
Author:
Cade Rea (cade-rea)
  • Method Details

    • getCookieValue

      public static String getCookieValue(String name, jakarta.servlet.http.HttpServletRequest request)
    • createSessionCookie

      @Deprecated public static jakarta.servlet.http.Cookie createSessionCookie(String cookieName, String content)
      Deprecated.
      Creates a cookie with attributes appropriate for a session cookie.
      Parameters:
      cookieName - the name of the cookie to create
      content - the value of the cookie
      Returns:
      the created cookie
    • createDeleteCookie

      @Deprecated public static jakarta.servlet.http.Cookie createDeleteCookie(String cookieName)
      Deprecated.
      Creates a cookie which will cause deletion of a previously set cookie.
      Parameters:
      cookieName - the name of the cookie
      Returns:
      the created cookie
    • createCookie

      @NonNull @Deprecated public static jakarta.servlet.http.Cookie createCookie(String cookieName, String content, int maxAge)
      Deprecated.
      Creates an HTTP-only, secure cookie with the given name, content, and max-age.
      Parameters:
      cookieName - the name of the cookie to create
      content - the cookie value
      maxAge - the max age for the cookie
      Returns:
      the created cookie
    • createSessionResponseCookie

      public static org.springframework.http.ResponseCookie createSessionResponseCookie(String cookieName, String content, String sameSite)
      Creates a cookie with attributes appropriate for a session cookie.
      Parameters:
      cookieName - the name of the cookie to create
      content - the value of the cookie
      sameSite - the SameSite attribute value for the cookie, ex: 'Lax', 'Strict', 'None'
      Returns:
      the created cookie
      See Also:
    • createSessionRemovalResponseCookie

      public static org.springframework.http.ResponseCookie createSessionRemovalResponseCookie(String cookieName, String sameSite)
      Creates a cookie which will cause deletion of a previously set cookie.
      Parameters:
      cookieName - the name of the cookie
      sameSite - the SameSite attribute value for the cookie, ex: 'Lax', 'Strict', 'None'
      Returns:
      the created cookie
      See Also:
    • createResponseCookie

      public static org.springframework.http.ResponseCookie createResponseCookie(String cookieName, String content, int maxAge, @Nullable String sameSite)
      Creates an HTTP-only, secure cookie with the given name, content, maxAge, and SameSite attributes.
      Parameters:
      cookieName - the name of the cookie to create
      content - the cookie value
      maxAge - the max age for the cookie
      sameSite - the SameSite attribute value for the cookie, ex: 'Lax', 'Strict', 'None'
      Returns:
      the created cookie