Stay organized with collections
Save and categorize content based on your preferences.
CookiePolicy
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 |
Will be called to see whether or not this cookie should be accepted.
|
Properties |
static CookiePolicy! |
One pre-defined policy which accepts all cookies.
|
static CookiePolicy! |
One pre-defined policy which accepts no cookies.
|
static CookiePolicy! |
One pre-defined policy which only accepts cookies from original server.
|
Public methods
shouldAccept
abstract fun shouldAccept(
uri: URI!,
cookie: HttpCookie!
): Boolean
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 |
Return |
Boolean |
true if this cookie should be accepted; otherwise, false |
Properties
ACCEPT_ALL
static val ACCEPT_ALL: CookiePolicy!
One pre-defined policy which accepts all cookies.
ACCEPT_NONE
static val ACCEPT_NONE: CookiePolicy!
One pre-defined policy which accepts no cookies.
ACCEPT_ORIGINAL_SERVER
static val ACCEPT_ORIGINAL_SERVER: CookiePolicy!
One pre-defined policy which only accepts cookies from original server.
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nCookiePolicy\n============\n\n```\ninterface CookiePolicy\n```\n\n|----------------------------|\n| [java.net.CookiePolicy](#) |\n\nCookiePolicy 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.\n\nSee RFC 2965 sec. 3.3 and 7 for more detail.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [shouldAccept](#shouldAccept(java.net.URI,%20java.net.HttpCookie))`(`uri:` `[URI](/reference/kotlin/java/net/URI)!`, `cookie:` `[HttpCookie](/reference/kotlin/java/net/HttpCookie)!`)` Will be called to see whether or not this cookie should be accepted. |\n\n| Properties ||\n|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [CookiePolicy](#)! | [ACCEPT_ALL](#ACCEPT_ALL:java.net.CookiePolicy) One pre-defined policy which accepts all cookies. |\n| static [CookiePolicy](#)! | [ACCEPT_NONE](#ACCEPT_NONE:java.net.CookiePolicy) One pre-defined policy which accepts no cookies. |\n| static [CookiePolicy](#)! | [ACCEPT_ORIGINAL_SERVER](#ACCEPT_ORIGINAL_SERVER:java.net.CookiePolicy) One pre-defined policy which only accepts cookies from original server. |\n\nPublic methods\n--------------\n\n### shouldAccept\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun shouldAccept(\n uri: URI!, \n cookie: HttpCookie!\n): Boolean\n```\n\nWill be called to see whether or not this cookie should be accepted.\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------|\n| `uri` | [URI](/reference/kotlin/java/net/URI)!: the URI to consult accept policy with |\n| `cookie` | [HttpCookie](/reference/kotlin/java/net/HttpCookie)!: the HttpCookie object in question |\n\n| Return ||\n|------------------------------------------------------------------------------------|--------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if this cookie should be accepted; otherwise, `false` |\n\nProperties\n----------\n\n### ACCEPT_ALL\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ACCEPT_ALL: CookiePolicy!\n```\n\nOne pre-defined policy which accepts all cookies. \n\n### ACCEPT_NONE\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ACCEPT_NONE: CookiePolicy!\n```\n\nOne pre-defined policy which accepts no cookies. \n\n### ACCEPT_ORIGINAL_SERVER\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ACCEPT_ORIGINAL_SERVER: CookiePolicy!\n```\n\nOne pre-defined policy which only accepts cookies from original server."]]