I want to set cookies in my HTTP POST request.
Something like the cookie field in the HTTP Request below,
version: 0.1.7
Cookie: client=Android; version=
Swift 3:
I had an array of cookies saved in my UserDefaults and what I did to attach them to the request was:
var request = URLRequest(url: "https://yourURL.com")
if let cookies = cookies as? [HTTPCookie] {
let headers = HTTPCookie.requestHeaderFields(with: cookies)
request.allHTTPHeaderFields = headers
}