Set alamofire cookies permenantly
up vote
0
down vote
favorite
I am using Alamofire for my requests and I get cookies in some of them, everything works fine when I launch the app and use it but when I kill the app and reopen the cookies are not there anymore. I searched a lot and found this but none of the answers helped. I try to save the cookies after each request and load them before sending request as below: func saveCookies(response: DataResponse<Any>) { let headerFields = response.response?.allHeaderFields as! [String: String] let url = response.response?.url let cookies = HTTPCookie.cookies(withResponseHeaderFields: headerFields, for: url!) var cookieArray = [[HTTPCookiePropertyKey: Any]]() for cookie in cookies { cookieArray.append(cookie.properties!) } UserDefaults.standard.set(cookieArray, forKey: &q