new Cookie()
Represents an HTTP Cookie.
All cookies must have a name and a value and can optionally have other fields set such as path, domain, etc.
(Derived from io.netty.handler.codec.http.Cookie)
Methods
-
encode() → {string}
-
Encode the cookie to a string. This is what is used in the Set-Cookie header
Returns:
the encoded cookie- Type
- string
-
getDomain() → {string}
-
Returns:
-
the domain for the cookie
-
- Type
- string
-
-
getName() → {string}
-
Returns:
-
the name of this cookie
-
- Type
- string
-
-
getPath() → {string}
-
Returns:
the path for this cookie- Type
- string
-
getValue() → {string}
-
Returns:
-
the value of this cookie
-
- Type
- string
-
-
isChanged() → {boolean}
-
Has the cookie been changed? Changed cookies will be saved out in the response and sent to the browser.
Returns:
true if changed- Type
- boolean
-
setChanged(changed)
-
Set the cookie as being changed. Changed will be true for a cookie just created, false by default if just read from the request
Parameters:
Name Type Description changed
boolean true if changed -
setDomain(domain) → {Cookie}
-
Sets the domain of this cookie
Parameters:
Name Type Description domain
string The domain to use Returns:
a reference to this, so the API can be used fluently- Type
- Cookie
-
setHttpOnly(httpOnly) → {Cookie}
-
Determines if this cookie is HTTP only. If set to true, this cookie cannot be accessed by a client side script. However, this works only if the browser supports it. For for information, please look here.
Parameters:
Name Type Description httpOnly
boolean True if the cookie is HTTP only, otherwise false. Returns:
- Type
- Cookie
-
setMaxAge(maxAge) → {Cookie}
-
Sets the maximum age of this cookie in seconds. If an age of
0
is specified, this cookie will be automatically removed by browser because it will expire immediately. If MIN_VALUE is specified, this cookie will be removed when the browser is closed. If you don't set this the cookie will be a session cookie and be removed when the browser is closed.Parameters:
Name Type Description maxAge
number The maximum age of this cookie in seconds Returns:
- Type
- Cookie
-
setPath(path) → {Cookie}
-
Sets the path of this cookie.
Parameters:
Name Type Description path
string The path to use for this cookie Returns:
a reference to this, so the API can be used fluently- Type
- Cookie
-
setSecure(secure) → {Cookie}
-
Sets the security getStatus of this cookie
Parameters:
Name Type Description secure
boolean True if this cookie is to be secure, otherwise false Returns:
a reference to this, so the API can be used fluently- Type
- Cookie
-
setValue(value) → {Cookie}
-
Sets the value of this cookie
Parameters:
Name Type Description value
string The value to set Returns:
a reference to this, so the API can be used fluently- Type
- Cookie