<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/HTTPCookieStorage/cookies(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSHTTPCookieStorage(im)cookiesForURL:"
  },
  "title" : "cookies(for:)"
}
-->

# cookies(for:)

Returns all the cookie storage’s cookies that are sent to a specified URL.

```
func cookies(for URL: URL) -> [HTTPCookie]?
```

## Parameters

`URL`

The URL to filter on.

## Return Value

An array of cookies whose URL matches the provided URL.

## Discussion

You can use the [`requestHeaderFields(with:)`](/documentation/Foundation/HTTPCookie/requestHeaderFields(with:)) method of [`HTTPCookie`](/documentation/Foundation/HTTPCookie) to turn the array returned by this method into a set of header fields to add to a [`URLRequest`](/documentation/Foundation/URLRequest) object (or [`NSMutableURLRequest`](/documentation/Foundation/NSMutableURLRequest) in Objective-C).

If you override this method, also override [`getCookiesFor(_:completionHandler:)`](/documentation/Foundation/HTTPCookieStorage/getCookiesFor(_:completionHandler:)).

---

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)