Stay organized with collections
Save and categorize content based on your preferences.
CookiePolicy
public
interface
CookiePolicy
CookiePolicy implementations decide which cookies should be accepted
and which should be rejected. Three pre-defined policy implementations
are provided, namely ACCEPT_ALL, ACCEPT_NONE and ACCEPT_ORIGINAL_SERVER.
See RFC 2965 sec. 3.3 and 7 for more detail.
Summary
Public methods |
abstract
boolean
|
shouldAccept(URI uri, HttpCookie cookie)
Will be called to see whether or not this cookie should be accepted.
|
Fields
ACCEPT_ALL
public static final CookiePolicy ACCEPT_ALL
One pre-defined policy which accepts all cookies.
ACCEPT_NONE
public static final CookiePolicy ACCEPT_NONE
One pre-defined policy which accepts no cookies.
ACCEPT_ORIGINAL_SERVER
public static final CookiePolicy ACCEPT_ORIGINAL_SERVER
One pre-defined policy which only accepts cookies from original server.
Public methods
shouldAccept
public abstract boolean shouldAccept (URI uri,
HttpCookie cookie)
Will be called to see whether or not this cookie should be accepted.
Parameters |
uri |
URI : the URI to consult accept policy with |
cookie |
HttpCookie : the HttpCookie object in question |
Returns |
boolean |
true if this cookie should be accepted;
otherwise, false |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# CookiePolicy\n\nAdded in [API level 9](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nCookiePolicy\n============\n\n\n`\npublic\n\n\ninterface\nCookiePolicy\n`\n\n\n`\n\n\n`\n\n|-----------------------|\n| java.net.CookiePolicy |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nCookiePolicy implementations decide which cookies should be accepted\nand which should be rejected. Three pre-defined policy implementations\nare provided, namely ACCEPT_ALL, ACCEPT_NONE and ACCEPT_ORIGINAL_SERVER.\n\nSee RFC 2965 sec. 3.3 and 7 for more detail.\n\nSummary\n-------\n\n| ### Fields ||\n|-------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` public static final `[CookiePolicy](/reference/java/net/CookiePolicy) | [ACCEPT_ALL](/reference/java/net/CookiePolicy#ACCEPT_ALL) One pre-defined policy which accepts all cookies. |\n| ` public static final `[CookiePolicy](/reference/java/net/CookiePolicy) | [ACCEPT_NONE](/reference/java/net/CookiePolicy#ACCEPT_NONE) One pre-defined policy which accepts no cookies. |\n| ` public static final `[CookiePolicy](/reference/java/net/CookiePolicy) | [ACCEPT_ORIGINAL_SERVER](/reference/java/net/CookiePolicy#ACCEPT_ORIGINAL_SERVER) One pre-defined policy which only accepts cookies from original server. |\n\n| ### Public methods ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[shouldAccept](/reference/java/net/CookiePolicy#shouldAccept(java.net.URI,%20java.net.HttpCookie))`(`[URI](/reference/java/net/URI)` uri, `[HttpCookie](/reference/java/net/HttpCookie)` cookie) ` Will be called to see whether or not this cookie should be accepted. |\n\nFields\n------\n\n### ACCEPT_ALL\n\nAdded in [API level 9](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final CookiePolicy ACCEPT_ALL\n```\n\nOne pre-defined policy which accepts all cookies.\n\n\u003cbr /\u003e\n\n### ACCEPT_NONE\n\nAdded in [API level 9](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final CookiePolicy ACCEPT_NONE\n```\n\nOne pre-defined policy which accepts no cookies.\n\n\u003cbr /\u003e\n\n### ACCEPT_ORIGINAL_SERVER\n\nAdded in [API level 9](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final CookiePolicy ACCEPT_ORIGINAL_SERVER\n```\n\nOne pre-defined policy which only accepts cookies from original server.\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### shouldAccept\n\nAdded in [API level 9](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean shouldAccept (URI uri, \n HttpCookie cookie)\n```\n\nWill be called to see whether or not this cookie should be accepted.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|--------------------------------------------------------|\n| `uri` | `URI`: the URI to consult accept policy with \u003cbr /\u003e |\n| `cookie` | `HttpCookie`: the HttpCookie object in question \u003cbr /\u003e |\n\n| Returns ||\n|-----------|---------------------------------------------------------------------|\n| `boolean` | `true` if this cookie should be accepted; otherwise, `false` \u003cbr /\u003e |"]]