<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/HTTPCookieStorage/storeCookies(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSHTTPCookieStorage(im)storeCookies:forTask:"
  },
  "title" : "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.

```
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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)