title: How to get cookie with URLSession request?
body: <p>I am sending one request using URLSession. I am getting the response but always value of HTTPCookieStorage.shared.cookies is 0 element. I am the testing in iOS simulator.</p>
  
  <pre><code>    guard let url = URL(string: "https://10.10.224.30/sdc/v2/common/token") else {
          return
      }
      let configuration = URLSessionConfiguration.default
      configuration.httpCookieAcceptPolicy = .always
  
      let mySession = URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
  
      var request = URLRequest(url: url)
      request.setValue("OTT_CLIENT", forHTTPHeaderField: "User-Agent")
      request.setValue("Basic aHR0cHdhdGNoOmY=", forHTTPHeaderField: "Authorization")
      request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
      request.setValue("11044", forHTTPHeaderField: "X-Device-Identifier")
      request.setValue("Deflate/gzip/compress",
                       forHTTPHeaderField: "Accept-Encoding")
      request.setValue("application/json", forHTTPHeaderField: "Accept")
      request.httpMethod = "POST"
  
      var urlParser = URLComponents()
      urlParser.queryItems = [
          URLQueryItem(name: "scope", value: "OpenId ONEApp"),
          URLQueryItem(name: "username", value: "2345679091"),
          URLQueryItem(name: "grant_type", value: "password"),
          URLQueryItem(name: "audience", value: "https://login.account.rakuten.com"),
          URLQueryItem(name: "nonce", value: "a1b2c3")
  
      ]
      let httpBodyString = urlParser.percentEncodedQuery
      request.httpBody = httpBodyString?.data(using: String.Encoding.utf8)
  
      let task = mySession.dataTask(with: request) { (data, response, error) in
  
          if let httpResponse = response as? HTTPURLResponse {
              let fields = httpResponse.allHeaderFields as! [String : String]
              var cookies1 =  URLSession.shared.configuration.httpCookieStorage?.cookies
  
              print(cookies1)
  
          }
  
      task.resume()
  </code></pre>