I am writing a REST client (with AFNetworking) and need the ability to trigger the creation of a new session within a single instance of an application.
In other words,
Even simpler.
[request setHTTPShouldHandleCookies:NO];
Rest calls as far as I know are not session based. Meaning you can't simulate an authentication and log-out session in a particular call. What I think you can do is to Authenticate for every call made to the end point. So for every end point(Method), you authenticate the caller. I think that's the bets you can do in a restful system.
Use AFHTTPClient
(see the API client in the example project).
Credentials can be set with -setAuthorizationHeaderWithUsername:password:
. Each request created from that HTTP client will have an Authorization
HTTP header, kind of like a browser session.
When the user logs out, or you want to clear credentials, do -clearAuthorizationHeader
.