<!--
{
  "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/HTTPCookie/requestHeaderFields(with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSHTTPCookie(cm)requestHeaderFieldsWithCookies:"
  },
  "title" : "requestHeaderFields(with:)"
}
-->

# requestHeaderFields(with:)

Converts an array of cookies to a dictionary of header fields.

```
class func requestHeaderFields(with cookies: [HTTPCookie]) -> [String : String]
```

## Parameters

`cookies`

The cookies from which the header fields are created.

## Return Value

The dictionary of header fields created from the provided cookies.

## Discussion

To send these headers as part of a URL request to a remote server, create an [`NSMutableURLRequest`](/documentation/Foundation/NSMutableURLRequest) object, then call the [`allHTTPHeaderFields`](/documentation/Foundation/NSMutableURLRequest/allHTTPHeaderFields) or [`setValue(_:forHTTPHeaderField:)`](/documentation/Foundation/NSMutableURLRequest/setValue(_:forHTTPHeaderField:)) method to set the provided headers for the request. Finally, initialize and start an [`URLSessionTask`](/documentation/Foundation/URLSessionTask) instance based on that request object.

---

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)