Class CookieUtil

    • Method Detail

      • getCookieValue

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

        @Deprecated
        public static javax.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 javax.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 javax.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:
        createResponseCookie(String, String, int, String)
      • 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(String, String, int, String)
      • 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