# CookieStore

public interface **CookieStore** A CookieStore object represents a storage for cookie. Can store and retrieve
cookies.

`https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieManager.html` will call `CookieStore.add` to save cookies
for every incoming HTTP response, and call `CookieStore.get` to
retrieve cookie for every outgoing HTTP request. A CookieStore
is responsible for removing HttpCookie instances which have expired.

### Public Method Summary

|---|---|
| abstract void | [add](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#add(java.net.URI,%20java.net.HttpCookie))([URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html) uri, [HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html) cookie) Adds one HTTP cookie to the store. |
| abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html)\> | [get](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#get(java.net.URI))([URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html) uri) Retrieve cookies associated with given URI, or whose domain matches the given URI. |
| abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html)\> | [getCookies](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#getCookies())() Get all not-expired cookies in cookie store. |
| abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html)\> | [getURIs](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#getURIs())() Get all URIs which identify the cookies in this cookie store. |
| abstract boolean | [remove](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#remove(java.net.URI,%20java.net.HttpCookie))([URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html) uri, [HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html) cookie) Remove a cookie from store. |
| abstract boolean | [removeAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#removeAll())() Remove all cookies in this cookie store. |

## Public Methods

#### public abstract void
**add**
([URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html) uri, [HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html) cookie)

Adds one HTTP cookie to the store. This is called for every
incoming HTTP response.

A cookie to store may or may not be associated with an URI. If it
is not associated with an URI, the cookie's domain and path attribute
will indicate where it comes from. If it is associated with an URI and
its domain and path attribute are not specified, given URI will indicate
where this cookie comes from.

If a cookie corresponding to the given URI already exists,
then it is replaced with the new one.

##### Parameters

| uri | the uri this cookie associated with. if `null`, this cookie will not be associated with an URI |
| cookie | the cookie to store |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `cookie` is `null` |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#get(java.net.URI)`

#### public abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html)\>
**get**
([URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html) uri)

Retrieve cookies associated with given URI, or whose domain matches the
given URI. Only cookies that have not expired are returned.
This is called for every outgoing HTTP request.

##### Parameters

| uri | the uri associated with the cookies to be returned |
|---|---|

##### Returns

- an immutable list of HttpCookie, return empty list if no cookies match the given URI

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `uri` is `null` |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/CookieStore.html#add(java.net.URI,%20java.net.HttpCookie)`

#### public abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html)\>
**getCookies**
()

Get all not-expired cookies in cookie store.

##### Returns

- an immutable list of http cookies; return empty list if there's no http cookie in store

#### public abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html)\>
**getURIs**
()

Get all URIs which identify the cookies in this cookie store.

##### Returns

- an immutable list of URIs; return empty list if no cookie in this cookie store is associated with an URI

#### public abstract boolean
**remove**
([URI](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html) uri, [HttpCookie](https://developers.google.com/j2objc/javadoc/jre/reference/java/net/HttpCookie.html) cookie)

Remove a cookie from store.

##### Parameters

| uri | the uri this cookie associated with. if `null`, the cookie to be removed is not associated with an URI when added; if not `null`, the cookie to be removed is associated with the given URI when added. |
| cookie | the cookie to remove |
|---|---|

##### Returns

- `true` if this store contained the specified cookie

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if `cookie` is `null` |
|---|---|

#### public abstract boolean
**removeAll**
()

Remove all cookies in this cookie store.

##### Returns

- `true` if this store changed as a result of the call