IOS AFNetworking - ASP.NET Web API. ASPXAUTH for storage and disposal

I am using the AFNetworking Framework for iOS. I subclassed AFHttpClient and used it as a singleton, i.e. [TestAFClient sharedClient]

I am using the ASP.NET web service API, which requires the use of cookie.ASPXAUTH. First I have to authenticate, get a cookie.ASPXAUTH in response, and then pass this cookie with each subsequent request.

After several tests, it seems that since I use singleton AFHTTPClient, cookie.ASPXAuth is saved and therefore no explicit cookie storage is required.

However, as part of my application, I need to “log out” at some point.

What is the most efficient way to clear this cookie in order to log out? Set singleton to nil and reinitialize it? Do something like setValue:forKey: :?

Also, is it better for me to explicitly store the cookie.ASPXAUTH? And does it expire or automatically resume when necessary?

Thank,

Robbie

+2
objective-c afnetworking sbjson .aspxauth
Mar 29 '12 at 21:18
source share
1 answer

Cookies are actually handled by the base URL loading system, similar to how caching is handled automatically by NSURLCache . For [NSHTTPCookieStorage sharedHTTPCookieStorage] you need to find the cookie on baseURL and then delete it. You can explicitly set or modify an existing cookie in the same way.

+11
Mar 29 2018-12-12T00:
source share



All Articles