Class NewCookie.AbstractNewCookieBuilder<T extends NewCookie.AbstractNewCookieBuilder<T>>

    • Constructor Detail

      • AbstractNewCookieBuilder

        public AbstractNewCookieBuilder​(String name)
        Create a new instance.
        Parameters:
        name - the name of the cookie.
      • AbstractNewCookieBuilder

        public AbstractNewCookieBuilder​(Cookie cookie)
        Create a new instance supplementing the information in the supplied cookie.
        Parameters:
        cookie - the cookie to clone.
    • Method Detail

      • comment

        public T comment​(String comment)
        Set the comment associated with the cookie.
        Parameters:
        comment - the comment.
        Returns:
        the updated builder instance.
      • maxAge

        public T maxAge​(int maxAge)
        Set the maximum age of the the cookie in seconds. Cookies older than the maximum age are discarded. A cookie can be unset by sending a new cookie with maximum age of 0 since it will overwrite any existing cookie and then be immediately discarded. The default value of -1 indicates that the cookie will be discarded at the end of the browser/application session.
        Parameters:
        maxAge - the maximum age in seconds.
        Returns:
        the updated builder instance.
        See Also:
        expiry(Date)
      • expiry

        public T expiry​(Date expiry)
        Set the cookie expiry date. Cookies whose expiry date has passed are discarded. A cookie can be unset by setting a new cookie with an expiry date in the past, typically the lowest possible date that can be set.

        Note that it is recommended to use Max-Age to control cookie expiration, however some browsers do not understand Max-Age, in which case setting Expires parameter may be necessary.

        Parameters:
        expiry - the cookie expiry date
        Returns:
        the updated builder instance.
        See Also:
        maxAge(int)
      • secure

        public T secure​(boolean secure)
        Whether the cookie will only be sent over a secure connection. Defaults to false.
        Parameters:
        secure - specifies whether the cookie will only be sent over a secure connection.
        Returns:
        the updated builder instance.
      • httpOnly

        public T httpOnly​(boolean httpOnly)
        Whether the cookie will only be visible as part of an HTTP request. Defaults to false.
        Parameters:
        httpOnly - if true make the cookie HTTP only, i.e. only visible as part of an HTTP request.
        Returns:
        the updated builder instance.
      • sameSite

        public T sameSite​(NewCookie.SameSite sameSite)
        Set the attribute that controls whether the cookie is sent with cross-origin requests, providing protection against cross-site request forgery.
        Parameters:
        sameSite - specifies the value of the SameSite cookie attribute.
        Returns:
        the updated builder instance.