# CookieManagerCompat

Artifact: [androidx.webkit:webkit](https://developer.android.com/jetpack/androidx/releases/webkit) [View Source](https://cs.android.com/search?q=file:androidx/webkit/CookieManagerCompat.java+class:androidx.webkit.CookieManagerCompat) Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.6.0)

*** ** * ** ***


```
@AnyThread
public class CookieManagerCompat
```

<br />

*** ** * ** ***

Compatibility version of `https://developer.android.com/reference/android/webkit/CookieManager.html`

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(name = https://developer.android.com/reference/androidx/webkit/WebViewFeature.GET_COOKIE_INFO, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported") https://developer.android.com/reference/androidx/webkit/CookieManagerCompat#getCookieInfo(android.webkit.CookieManager,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/CookieManager.html cookieManager, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html url)` Gets all the cookies for the given URL along with their set attributes. |

## Public methods

### getCookieInfo

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/webkit#1.6.0)

```
@RequiresFeature(name = WebViewFeature.GET_COOKIE_INFO, enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
public static @NonNull List<String> getCookieInfo(@NonNull CookieManager cookieManager, @NonNull String url)
```

Gets all the cookies for the given URL along with their set attributes. The cookies are returned in the format of the HTTP 'Set-Cookie' header as defined in [the RFC6265 spec.](https://httpwg.org/specs/rfc6265.html#sane-set-cookie-syntax) eg. "name=value; domain=.example.com; path=/"

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/webkit/CookieManager.html cookieManager` | The CookieManager instance to get info from. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html url` | the URL for which the API retrieves all available cookies. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | the cookies as a list of strings. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` | if the `https://developer.android.com/reference/androidx/webkit/WebViewFeature#GET_COOKIE_INFO()` feature is not supported. This should be checked before use with `https://developer.android.com/reference/androidx/webkit/WebViewFeature#isFeatureSupported(java.lang.String)`. |