# CookieManager

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/webkit/CookieManager#pubctors)\|[Methods](https://developer.android.com/reference/android/webkit/CookieManager#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/webkit/CookieManager#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/webkit/CookieManager#inhmethods)  

# CookieManager

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/webkit/CookieManager "View this page in Kotlin")\|Java

`
public


abstract
class
CookieManager
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.webkit.CookieManager |

<br />

*** ** * ** ***

Manages the cookies used by an application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances.

CookieManager represents cookies as strings in the same format as the HTTP`Cookie`and`Set-Cookie`header fields (defined in[RFC6265bis](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03)).

## Summary

|                                                                                                                                                                 ### Public constructors                                                                                                                                                                 ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[CookieManager](https://developer.android.com/reference/android/webkit/CookieManager#CookieManager())`() ` *This constructor is deprecated. This class should not be constructed by applications, use[getInstance()](https://developer.android.com/reference/android/webkit/CookieManager#getInstance())instead to fetch the singleton instance.* |

|                                                                                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                                                                                  ||
|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract boolean`                                                                             | ` `[acceptCookie](https://developer.android.com/reference/android/webkit/CookieManager#acceptCookie())`() ` Gets whether the application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances send and accept cookies.                                                                                                                                                                                                                                                                                                                               |
| ` abstract boolean`                                                                             | ` `[acceptThirdPartyCookies](https://developer.android.com/reference/android/webkit/CookieManager#acceptThirdPartyCookies(android.webkit.WebView))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` webview) ` Gets whether the[WebView](https://developer.android.com/reference/android/webkit/WebView)should allow third party cookies to be set.                                                                                                                                                                                                     |
| ` static boolean`                                                                               | ` `[allowFileSchemeCookies](https://developer.android.com/reference/android/webkit/CookieManager#allowFileSchemeCookies())`() ` Gets whether the application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances send and accept cookies for file scheme URLs.                                                                                                                                                                                                                                                                                      |
| ` abstract void`                                                                                | ` `[flush](https://developer.android.com/reference/android/webkit/CookieManager#flush())`() ` Ensures all cookies currently accessible through the getCookie API are written to persistent storage.                                                                                                                                                                                                                                                                                                                                                                                 |
| ` abstract `[String](https://developer.android.com/reference/java/lang/String)                  | ` `[getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` url) ` Gets all the cookies for the given URL.                                                                                                                                                                                                                                                                                                                                               |
| ` static `[CookieManager](https://developer.android.com/reference/android/webkit/CookieManager) | ` `[getInstance](https://developer.android.com/reference/android/webkit/CookieManager#getInstance())`() ` Gets the singleton CookieManager instance.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` abstract boolean`                                                                             | ` `[hasCookies](https://developer.android.com/reference/android/webkit/CookieManager#hasCookies())`() ` Gets whether there are stored cookies.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ` abstract void`                                                                                | ` `[removeAllCookie](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookie())`() ` *This method was deprecated in API level 21. Use[removeAllCookies(android.webkit.ValueCallback)](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback<java.lang.Boolean>))instead.*                                                                                                                                                                                                                 |
| ` abstract void`                                                                                | ` `[removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback<java.lang.Boolean>))`(`[ValueCallback](https://developer.android.com/reference/android/webkit/ValueCallback)`<`[Boolean](https://developer.android.com/reference/java/lang/Boolean)`> callback) ` Removes all cookies.                                                                                                                                                                                                                     |
| ` abstract void`                                                                                | ` `[removeExpiredCookie](https://developer.android.com/reference/android/webkit/CookieManager#removeExpiredCookie())`() ` *This method was deprecated in API level 21. The WebView handles removing expired cookies automatically.*                                                                                                                                                                                                                                                                                                                                                 |
| ` abstract void`                                                                                | ` `[removeSessionCookie](https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookie())`() ` *This method was deprecated in API level 21. use[removeSessionCookies(android.webkit.ValueCallback)](https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback<java.lang.Boolean>))instead.*                                                                                                                                                                                                 |
| ` abstract void`                                                                                | ` `[removeSessionCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback<java.lang.Boolean>))`(`[ValueCallback](https://developer.android.com/reference/android/webkit/ValueCallback)`<`[Boolean](https://developer.android.com/reference/java/lang/Boolean)`> callback) ` Removes all session cookies, which are cookies without an expiration date.                                                                                                                                                       |
| ` abstract void`                                                                                | ` `[setAcceptCookie](https://developer.android.com/reference/android/webkit/CookieManager#setAcceptCookie(boolean))`(boolean accept) ` Sets whether the application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances should send and accept cookies.                                                                                                                                                                                                                                                                                             |
| ` static void`                                                                                  | ` `[setAcceptFileSchemeCookies](https://developer.android.com/reference/android/webkit/CookieManager#setAcceptFileSchemeCookies(boolean))`(boolean accept) ` *This method was deprecated in API level 30. This setting is not secure, please use[androidx.webkit.WebViewAssetLoader](https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader)instead.*                                                                                                                                                                                                           |
| ` abstract void`                                                                                | ` `[setAcceptThirdPartyCookies](https://developer.android.com/reference/android/webkit/CookieManager#setAcceptThirdPartyCookies(android.webkit.WebView,%20boolean))`(`[WebView](https://developer.android.com/reference/android/webkit/WebView)` webview, boolean accept) ` Sets whether the[WebView](https://developer.android.com/reference/android/webkit/WebView)should allow third party cookies to be set.                                                                                                                                                                    |
| ` abstract void`                                                                                | ` `[setCookie](https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback<java.lang.Boolean>))`(`[String](https://developer.android.com/reference/java/lang/String)` url, `[String](https://developer.android.com/reference/java/lang/String)` value, `[ValueCallback](https://developer.android.com/reference/android/webkit/ValueCallback)`<`[Boolean](https://developer.android.com/reference/java/lang/Boolean)`> callback) ` Sets a single cookie (key-value pair) for the given URL. |
| ` abstract void`                                                                                | ` `[setCookie](https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` url, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Sets a single cookie (key-value pair) for the given URL.                                                                                                                                                                                                                              |

|                                                                                              ### Protected methods                                                                                              ||
|-----------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Object](https://developer.android.com/reference/java/lang/Object) | ` `[clone](https://developer.android.com/reference/android/webkit/CookieManager#clone())`() ` Creates and returns a copy of this object. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### CookieManager

Added in[API level 22](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public CookieManager ()
```

<br />

**This constructor is deprecated.**   
This class should not be constructed by applications, use[getInstance()](https://developer.android.com/reference/android/webkit/CookieManager#getInstance())instead to fetch the singleton instance.

<br />

<br />

## Public methods

### acceptCookie

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean acceptCookie ()
```

Gets whether the application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances send and accept cookies.

<br />

|                                                               Returns                                                                ||
|-----------|---------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`if[WebView](https://developer.android.com/reference/android/webkit/WebView)instances send and accept cookies <br /> |

### acceptThirdPartyCookies

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean acceptThirdPartyCookies (WebView webview)
```

Gets whether the[WebView](https://developer.android.com/reference/android/webkit/WebView)should allow third party cookies to be set.

<br />

|                                                                   Parameters                                                                   ||
|-----------|-------------------------------------------------------------------------------------------------------------------------------------|
| `webview` | `WebView`: the[WebView](https://developer.android.com/reference/android/webkit/WebView)instance to get the cookie policy for <br /> |

|                                                              Returns                                                               ||
|-----------|-------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`if the[WebView](https://developer.android.com/reference/android/webkit/WebView)accepts third party cookies <br /> |

### allowFileSchemeCookies

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static boolean allowFileSchemeCookies ()
```

Gets whether the application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances send and accept cookies for file scheme URLs.

<br />

|                                                                          Returns                                                                          ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`if[WebView](https://developer.android.com/reference/android/webkit/WebView)instances send and accept cookies for file scheme URLs <br /> |

### flush

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void flush ()
```

Ensures all cookies currently accessible through the getCookie API are written to persistent storage. This call will block the caller until it is done and may perform I/O.

<br />

### getCookie

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract String getCookie (String url)
```

Gets all the cookies for the given URL. This may return multiple key-value pairs if multiple cookies are associated with this URL, in which case each cookie will be delimited by`"; "`characters (semicolon followed by a space). Each key-value pair will be of the form`"key=value"`.

**Note:** Any cookies set with the`"Partitioned"`attribute will only be returned for the top-level partition of`url`.

<br />

|                             Parameters                              ||
|-------|--------------------------------------------------------------|
| `url` | `String`: the URL for which the cookies are requested <br /> |

|                                                                            Returns                                                                             ||
|--------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | value the cookies as a string, using the format of the 'Cookie' HTTP request header <br /> |

### getInstance

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static CookieManager getInstance ()
```

Gets the singleton CookieManager instance.

<br />

|                                                              Returns                                                               ||
|---------------------------------------------------------------------------------------|---------------------------------------------|
| [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager) | the singleton CookieManager instance <br /> |

### hasCookies

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean hasCookies ()
```

Gets whether there are stored cookies.

<br />

|                       Returns                       ||
|-----------|------------------------------------------|
| `boolean` | `true`if there are stored cookies <br /> |

### removeAllCookie

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeAllCookie ()
```

<br />

**This method was deprecated in API level 21.**   
Use[removeAllCookies(android.webkit.ValueCallback)](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback<java.lang.Boolean>))instead.

Removes all cookies.

<br />

### removeAllCookies

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeAllCookies (ValueCallback<Boolean> callback)
```

Removes all cookies.

This method is asynchronous. If a[ValueCallback](https://developer.android.com/reference/android/webkit/ValueCallback)is provided,[onReceiveValue()](https://developer.android.com/reference/android/webkit/ValueCallback#onReceiveValue(T))will be called on the current thread's[Looper](https://developer.android.com/reference/android/os/Looper)once the operation is complete. The value provided to the callback indicates whether any cookies were removed. You can pass`null`as the callback if you don't need to know when the operation completes or whether any cookies were removed, and in this case it is safe to call the method from a thread without a Looper.

<br />

|                                                          Parameters                                                          ||
|------------|------------------------------------------------------------------------------------------------------------------|
| `callback` | `ValueCallback`: a callback which is executed when the cookies have been removed This value may be`null`. <br /> |

### removeExpiredCookie

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeExpiredCookie ()
```

<br />

**This method was deprecated in API level 21.**   
The WebView handles removing expired cookies automatically.

Removes all expired cookies.

<br />

### removeSessionCookie

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeSessionCookie ()
```

<br />

**This method was deprecated in API level 21.**   
use[removeSessionCookies(android.webkit.ValueCallback)](https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback<java.lang.Boolean>))instead.

Removes all session cookies, which are cookies without an expiration date.

<br />

### removeSessionCookies

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeSessionCookies (ValueCallback<Boolean> callback)
```

Removes all session cookies, which are cookies without an expiration date.

This method is asynchronous. If a[ValueCallback](https://developer.android.com/reference/android/webkit/ValueCallback)is provided,[onReceiveValue()](https://developer.android.com/reference/android/webkit/ValueCallback#onReceiveValue(T))will be called on the current thread's[Looper](https://developer.android.com/reference/android/os/Looper)once the operation is complete. The value provided to the callback indicates whether any cookies were removed. You can pass`null`as the callback if you don't need to know when the operation completes or whether any cookie were removed, and in this case it is safe to call the method from a thread without a Looper.

<br />

|                                                              Parameters                                                              ||
|------------|--------------------------------------------------------------------------------------------------------------------------|
| `callback` | `ValueCallback`: a callback which is executed when the session cookies have been removed This value may be`null`. <br /> |

### setAcceptCookie

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setAcceptCookie (boolean accept)
```

Sets whether the application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances should send and accept cookies. By default this is set to`true`and the WebView accepts cookies.

When this is`true`[setAcceptThirdPartyCookies](https://developer.android.com/reference/android/webkit/CookieManager#setAcceptThirdPartyCookies(android.webkit.WebView,%20boolean))and[setAcceptFileSchemeCookies](https://developer.android.com/reference/android/webkit/CookieManager#setAcceptFileSchemeCookies(boolean))can be used to control the policy for those specific types of cookie.

<br />

|                                                                      Parameters                                                                      ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `accept` | `boolean`: whether[WebView](https://developer.android.com/reference/android/webkit/WebView)instances should send and accept cookies <br /> |

### setAcceptFileSchemeCookies

Added in[API level 12](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void setAcceptFileSchemeCookies (boolean accept)
```

<br />

**This method was deprecated in API level 30.**   
This setting is not secure, please use[androidx.webkit.WebViewAssetLoader](https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader)instead.

Sets whether the application's[WebView](https://developer.android.com/reference/android/webkit/WebView)instances should send and accept cookies for file scheme URLs.

Use of cookies with file scheme URLs is potentially insecure and turned off by default. All`file://`URLs share all their cookies, which may lead to leaking private app cookies (ex. any malicious file can access cookies previously set by other (trusted) files).

Loading content via`file://`URLs is generally discouraged. See the note in[WebSettings.setAllowFileAccess](https://developer.android.com/reference/android/webkit/WebSettings#setAllowFileAccess(boolean)). Using[androidx.webkit.WebViewAssetLoader](https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader)to load files over`http(s)://`URLs allows the standard web security model to be used for setting and sharing cookies for local files.

Note that calls to this method will have no effect if made after calling other[CookieManager](https://developer.android.com/reference/android/webkit/CookieManager)APIs.

<br />

|         Parameters         ||
|----------|------------------|
| `accept` | `boolean` <br /> |

### setAcceptThirdPartyCookies

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setAcceptThirdPartyCookies (WebView webview, 
                boolean accept)
```

Sets whether the[WebView](https://developer.android.com/reference/android/webkit/WebView)should allow third party cookies to be set. Allowing third party cookies is a per WebView policy and can be set differently on different WebView instances.

Apps that target[Build.VERSION_CODES.KITKAT](https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT)or below default to allowing third party cookies. Apps targeting[Build.VERSION_CODES.LOLLIPOP](https://developer.android.com/reference/android/os/Build.VERSION_CODES#LOLLIPOP)or later default to disallowing third party cookies.

<br />

|                                                                         Parameters                                                                          ||
|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| `webview` | `WebView`: the[WebView](https://developer.android.com/reference/android/webkit/WebView)instance to set the cookie policy on <br />               |
| `accept`  | `boolean`: whether the[WebView](https://developer.android.com/reference/android/webkit/WebView)instance should accept third party cookies <br /> |

### setCookie

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setCookie (String url, 
                String value, 
                ValueCallback<Boolean> callback)
```

Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired. To set multiple cookies, your application should invoke this method multiple times.

The`value`parameter must follow the format of the`Set-Cookie`HTTP response header. This is a key-value pair of the form`"key=value"`, optionally followed by a list of cookie attributes delimited with semicolons (ex.`"key=value; Max-Age=123"`). For the header format and attributes supported by WebView, see the[`Set-Cookie`documentation on MDN](https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie).

This method is asynchronous. If a[ValueCallback](https://developer.android.com/reference/android/webkit/ValueCallback)is provided,[ValueCallback.onReceiveValue](https://developer.android.com/reference/android/webkit/ValueCallback#onReceiveValue(T))will be called on the current thread's[Looper](https://developer.android.com/reference/android/os/Looper)once the operation is complete. The value provided to the callback indicates whether the cookie was set successfully. You can pass`null`as the callback if you don't need to know when the operation completes or whether it succeeded, and in this case it is safe to call the method from a thread without a Looper.

**Notes:**

- If specifying a`value`containing the`"Secure"`attribute,`url`must use the`"https://"`scheme.
- if specifying a`value`containing the`"Partitioned"`attribute, the cookie will be set for the top-level partition of the`url`.

<br />

<br />

|                                                     Parameters                                                      ||
|------------|---------------------------------------------------------------------------------------------------------|
| `url`      | `String`: the URL for which the cookie is to be set <br />                                              |
| `value`    | `String`: the cookie as a string, using the format of the 'Set-Cookie' HTTP response header <br />      |
| `callback` | `ValueCallback`: a callback to be executed when the cookie has been set This value may be`null`. <br /> |

### setCookie

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setCookie (String url, 
                String value)
```

Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same host, path and name will be replaced with the new cookie. The cookie being set will be ignored if it is expired. To set multiple cookies, your application should invoke this method multiple times.

The`value`parameter must follow the format of the`Set-Cookie`HTTP response header. This is a key-value pair of the form`"key=value"`, optionally followed by a list of cookie attributes delimited with semicolons (ex.`"key=value; Max-Age=123"`). For the header format and attributes supported by WebView, see the[`Set-Cookie`documentation on MDN](https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie).

**Notes:**

- If specifying a`value`containing the`"Secure"`attribute,`url`must use the`"https://"`scheme.
- if specifying a`value`containing the`"Partitioned"`attribute, the cookie will be set for the top-level partition of the`url`.

<br />

<br />

|                                                 Parameters                                                  ||
|---------|----------------------------------------------------------------------------------------------------|
| `url`   | `String`: the URL for which the cookie is to be set <br />                                         |
| `value` | `String`: the cookie as a string, using the format of the 'Set-Cookie' HTTP response header <br /> |

## Protected methods

### clone

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected Object clone ()
```

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object`x`, the expression:
>
> ```
>  x.clone() != x
> ```
will be true, and that the expression:
>
> ```
>  x.clone().getClass() == x.getClass()
> ```
will be`true`, but these are not absolute requirements. While it is typically the case that:
>
> ```
>  x.clone().equals(x)
> ```
will be`true`, this is not an absolute requirement.

By convention, the returned object should be obtained by calling`super.clone`. If a class and all of its superclasses (except`Object`) obey this convention, it will be the case that`x.clone().getClass() == x.getClass()`.

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by`super.clone`before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by`super.clone`need to be modified.

<br />

|                                               Returns                                                ||
|--------------------------------------------------------------------|----------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | a clone of this instance. <br /> |

|                                                    Throws                                                     ||
|------------------------------------------------------------------------------------------------------------|---|
| [CloneNotSupportedException](https://developer.android.com/reference/java/lang/CloneNotSupportedException) |   |