---
title: "storeCookies(_:for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/httpcookiestorage/storecookies(_:for:)"
---

# storeCookies(_:for:)

Stores an array of cookies in the cookie storage, on behalf of the provided task, if the cookie accept policy permits.

## Declaration

```swift
func storeCookies(_ cookies: [HTTPCookie], for task: URLSessionTask)
```

## Parameters

- `cookies`: The cookies to add.
- `task`: The task that handles the response. Override this method and inspect this parameter if you need to alter your cookie storage strategy based on properties of the task.

## See Also

### Adding and removing cookies

- [removeCookies(since:)](foundation/httpcookiestorage/removecookies(since:).md)
- [deleteCookie(_:)](foundation/httpcookiestorage/deletecookie(_:).md)
- [setCookie(_:)](foundation/httpcookiestorage/setcookie(_:).md)
- [setCookies(_:for:mainDocumentURL:)](foundation/httpcookiestorage/setcookies(_:for:maindocumenturl:).md)
