Interface Cookie
- All Superinterfaces:
Comparable<Cookie>
- All Known Subinterfaces:
Cookie
- All Known Implementing Classes:
DefaultCookie, DefaultCookie
An interface defining an
HTTP cookie.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longConstant for undefined MaxAge attribute value. -
Method Summary
Modifier and TypeMethodDescriptiondomain()Returns the domain of thisCookie.booleanChecks to see if thisCookiecan only be accessed via HTTP.booleanisSecure()Checks to see if thisCookieis securelongmaxAge()Returns the maximum age of thisCookiein seconds orUNDEFINED_MAX_AGEif unspecifiedname()Returns the name of thisCookie.path()Returns the path of thisCookie.voidSets the domain of thisCookie.voidsetHttpOnly(boolean httpOnly) Determines if thisCookieis HTTP only.voidsetMaxAge(long maxAge) Sets the maximum age of thisCookiein seconds.voidSets the path of thisCookie.voidsetSecure(boolean secure) Sets the security getStatus of thisCookievoidSets the value of thisCookie.voidsetWrap(boolean wrap) Sets true if the value of thisCookieis to be wrapped with double quotes.value()Returns the value of thisCookie.booleanwrap()Returns true if the raw value of thisCookie, was wrapped with double quotes in original Set-Cookie header.Methods inherited from interface Comparable
compareTo
-
Field Details
-
UNDEFINED_MAX_AGE
static final long UNDEFINED_MAX_AGEConstant for undefined MaxAge attribute value.- See Also:
-
-
Method Details
-
name
-
value
-
setValue
-
wrap
-
setWrap
void setWrap(boolean wrap) Sets true if the value of thisCookieis to be wrapped with double quotes.- Parameters:
wrap- true if wrap
-
domain
-
setDomain
-
path
-
setPath
-
maxAge
long maxAge()Returns the maximum age of thisCookiein seconds orUNDEFINED_MAX_AGEif unspecified- Returns:
- The maximum age of this
Cookie
-
setMaxAge
void setMaxAge(long maxAge) Sets the maximum age of thisCookiein seconds. If an age of0is specified, thisCookiewill be automatically removed by browser because it will expire immediately. IfUNDEFINED_MAX_AGEis specified, thisCookiewill be removed when the browser is closed.- Parameters:
maxAge- The maximum age of thisCookiein seconds
-
isSecure
-
setSecure
-
isHttpOnly
boolean isHttpOnly()Checks to see if thisCookiecan only be accessed via HTTP. If this returns true, theCookiecannot be accessed through client side script - But only if the browser supports it. For more information, please look here- Returns:
- True if this
Cookieis HTTP-only or false if it isn't
-
setHttpOnly
void setHttpOnly(boolean httpOnly) Determines if thisCookieis HTTP only. If set to true, thisCookiecannot be accessed by a client side script. However, this works only if the browser supports it. For information, please look here.- Parameters:
httpOnly- True if theCookieis HTTP only, otherwise false.
-