Swift 2.0, Alamofire: Set cookies in HTTP Post Request

前端 未结 4 571
长情又很酷
长情又很酷 2021-02-14 00:48

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=         


        
4条回答
  •  日久生厌
    2021-02-14 01:42

    iOS 11 & Alamofire 4

    let webDataStore = webView.configuration.websiteDataStore
    webDataStore.httpCookieStore.getAllCookies { (cookies) in
        Alamofire.SessionManager.default.session.configuration.httpCookieStorage?.setCookies(
            cookies,
            for: url,
            mainDocumentURL: nil
        )
    }
    

提交回复
热议问题