Steve
Steve

Reputation: 130

Does URLSession persist cookies?

If the app makes a request that returns a response with a Set-Cookie header, the next time when I open the app and make the same request, will it attach the cookie from previous call?

let task = URLSession.shared.dataTask(with: url, completionHandler: { data, response, error in
    })
task.resume()

Upvotes: 1

Views: 1018

Answers (1)

BoygeniusDexter
BoygeniusDexter

Reputation: 2262

If you use default or background URLSessionConfiguration then cookies will be persisted.

More info: https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1411599-httpcookiestorage

Upvotes: 2

Related Questions