---
title: "requestHeaderFields(with:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/httpcookie/requestheaderfields(with:)"
---

# requestHeaderFields(with:)

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

## Declaration

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

## Parameters

- `cookies`: The cookies from which the header fields are created.

## Return Value

Return Value The dictionary of header fields created from the provided cookies.

## Discussion

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