I sent request to url1. url1 will redirect to url2 with cookie. url2 is for authorization. And I get code \"302 found\", which is correct. But when url2 redirect back to ur
recently i faced same problem and i fixed this problem by doing this.I am sure cookie lost happen only if you are using iOS < 11, for this you need to apply some work around as i applied recently.
1- pass updated cookies in response from server side.Whenever it changed from server,
Read cookie from response like this way.
if let allHttpHeaders = response.allHeaderFields as? [String: String] {
let cookies = HTTPCookie.cookies(withResponseHeaderFields: allHttpHeaders, for: responseUrl)
for cookie in cookies {
if cookie.name == "cookie name" {
// compare with old cookie value so it will show your cookie is changed now.
if "your_old_cookie_value" != cookie.value {
//update cookie in Script and request header
// reload your page here again.
break
}
}
}
}
This is the minimal change by that you can fix cookie lost issue, for iOS >=11 should not be an issue, for ios 11 and above use httpcookiestore
Let me know if you have any question.