How to set Cookies in Alamofire such that such that every time I kill the app and restart it, the same cookie is sent?
Prepare your cookies
let cookieProps = [
HTTPCookiePropertyKey.domain: "##put your domain here##",
HTTPCookiePropertyKey.path: "/",
HTTPCookiePropertyKey.name: "##put your cookie key here##",
HTTPCookiePropertyKey.value: "##put your cookie value here##"
]
Set your cookies
if let cookie = HTTPCookie(properties: cookieProps) {
AF.session.configuration.httpCookieStorage?.setCookie(cookie)
}
After that, you can do your normal request and the cookies will be sent to server
Alamofire.request(
##URL##,
method: ##.post or .get##,
parameters: parameters
).responseString {
response in
....
}