public class CookieManager extends Object implements Serializable
WebClient
. This class is thread-safe.
You can disable Cookies by calling setCookiesEnabled(false). The
CookieManager itself takes care of this and ignores all cookie request if
disabled. If you override this your methods have to do the same.Constructor and Description |
---|
CookieManager()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addCookie(Cookie cookie)
Adds the specified cookie.
|
void |
clearCookies()
Removes all cookies.
|
boolean |
clearExpired(Date date)
Clears all cookies that have expired before supplied date.
|
Cookie |
getCookie(String name)
Returns the currently configured cookie with the specified name, or
null if one does not exist. |
Set<Cookie> |
getCookies()
Returns the currently configured cookies, in an unmodifiable set.
|
boolean |
isCookiesEnabled()
Returns
true if cookies are enabled. |
void |
removeCookie(Cookie cookie)
Removes the specified cookie.
|
void |
setCookiesEnabled(boolean enabled)
Enables/disables cookie support.
|
public void setCookiesEnabled(boolean enabled)
enabled
- true
to enable cookie support, false
otherwisepublic boolean isCookiesEnabled()
true
if cookies are enabled. Cookies are enabled by default.true
if cookies are enabled, false
otherwisepublic Set<Cookie> getCookies()
public boolean clearExpired(Date date)
date
- the date to use for comparison when clearing expired cookiespublic Cookie getCookie(String name)
null
if one does not exist.
If disabled, this returns null.name
- the name of the cookie to returnnull
if one does not existpublic void addCookie(Cookie cookie)
cookie
- the cookie to addpublic void removeCookie(Cookie cookie)
cookie
- the cookie to removepublic void clearCookies()
Copyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.