Package io.muserver

Class Cookie


  • public class Cookie
    extends java.lang.Object
    A cookie that is sent from the server to the client.

    To create cookies, you can create a builder by calling builder().

    • Method Detail

      • name

        public java.lang.String name()
        Returns:
        The cookie name
      • value

        public java.lang.String value()
        Returns:
        The cookie value
      • domain

        public java.lang.String domain()
        Returns:
        The domain this cookie is valid for
      • path

        public java.lang.String path()
        Returns:
        The path this cookie applies to
      • maxAge

        public long maxAge()
        Returns:
        The max age in seconds of this cookie
      • sameSite

        public java.lang.String sameSite()
        Returns:
        The SameSite value of the cookie, for example "Strict", "Lax", or "None"
      • isSecure

        public boolean isSecure()
        Returns:
        True if this cookie is only readable over https
      • isHttpOnly

        public boolean isHttpOnly()
        Returns:
        True if this cookie is only available via HTTP. If false, client side script will not be able to read the cookie (if the client supports this).
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • builder

        public static CookieBuilder builder()
        Creates a new cookie builder with secure, Strict SameSite and httpOnly selected.
        Returns:
        A new builder