Class CookieUtil


  • public class CookieUtil
    extends Object
    Class to get and set cookies
    Author:
    vanderw
    • Constructor Detail

      • CookieUtil

        public CookieUtil()
    • Method Detail

      • getCookie

        public static javax.servlet.http.Cookie getCookie​(javax.servlet.http.HttpServletRequest request,
                                                          String name)
        Gets a cookie
        Parameters:
        request - the HttpServletRequest
        name - the name of the cookie
        Returns:
        the cookie
      • getCookieValue

        public static String getCookieValue​(javax.servlet.http.HttpServletRequest request,
                                            String name)
        Returns the value of a cookie if present
        Parameters:
        request - the HttpServletRequest
        name - the name of the cookie
        Returns:
        the value of the cookie with the name specified
      • setCookie

        public static void setCookie​(javax.servlet.http.HttpServletResponse response,
                                     String name,
                                     String value,
                                     String path,
                                     int expirySeconds,
                                     boolean secure,
                                     String domain)
        Sets a cookie
        Parameters:
        response - the HttpServletResponse
        name - the name of the cookie
        value - the value of the cookie
        path - the patch of the cookie
        expirySeconds - the expiry time of the cookie in seconds
        secure - indicating if it has to be secure
        domain - the domain on which the cookie has to be set