sbekir
sbekir

Reputation: 67

How to check which cookies are sent on Alamofire request?

I am using Alamofire for API requests. I need to check which cookies are sent on request.

NetworkService.configuration.httpCookieStorage?.setCookies(cookies, for: try url.asURL(), mainDocumentURL: nil)

I use this for set cookies but i can't see if it is set or not. Is there any way to check this?

Upvotes: 0

Views: 536

Answers (2)

hites
hites

Reputation: 159

You can try this:

HTTPCookieStorage.shared.cookies

Upvotes: 1

Hitesh Surani
Hitesh Surani

Reputation: 13567

You can use the below code to find

let cookies = HTTPCookie.cookies(withResponseHeaderFields: headerFields, for: URL)
print(cookies)

OR

You can use this(View all cookies).

HTTPCookieStorage.shared.cookies

Upvotes: 3

Related Questions