Can AFNetworking 2 store the cookies

拜拜、爱过 提交于 2019-12-05 20:18:27
Aaron Brager

From Persisting Cookies in an iOS Application:

Cookies without an expiry date are considered 'session only' and will get cleared when you restart the app. You can check the 'session only' situation via a BOOL property in NSHTTPCookie. This is standard cookie stuff and not something specific to iOS.

AFNetworking does not do anything with cookies under the hood. It does use NSURLConnection, and NSURLConnection uses NSHTTPCookieStorage.

According to your log:

<NSHTTPCookie version:0 name:"...." value:"....." expiresDate:(null) created:2014-02-27 19:24:29 +0000 (4.15222e+08) sessionOnly:TRUE domain:"...." path:"/" isSecure:FALSE>

you have session only cookies ("sessionOnly:TRUE").

You need to add an expiration date on the server end so that NSHTTPCookieStorage doesn't throw them away when your session ends.

This is not anything AFNetworking-specific; it's just how cookies work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!