---
title: "cookies(withResponseHeaderFields:for:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/httpcookie/cookies(withresponseheaderfields:for:)"
---

# cookies(withResponseHeaderFields:for:)

Creates an array of HTTP cookies that corresponds to the provided response header fields for the provided URL.

## Declaration

```swift
class func cookies(withResponseHeaderFields headerFields: [String : String], for URL: URL) -> [HTTPCookie]
```

## Parameters

- `headerFields`: The header fields used to create the doc://com.apple.foundation/documentation/Foundation/HTTPCookie objects.
- `URL`: The URL associated with the created cookies.

## Return Value

Return Value The array of created cookies.

## Discussion

Discussion This method ignores irrelevant header fields in headerFields, allowing dictionaries to contain additional data. If headerFields doesn’t specify a domain for a given cookie, the cookie is created with a default domain value of URL. If headerFields doesn’t specify a path for a given cookie, the cookie is created with a default path value of "/".

## See Also

### Creating cookies

- [init(properties:)](foundation/httpcookie/init(properties:).md)
