Reputation: 3557
Im using the following code to a interface to login with basic http authentication.
RKRequest *loginRequest = [[RKRequest alloc] initWithURL:URL];
loginRequest.timeoutInterval = REST_LOGIN_TIMEOUT;
loginRequest.username = username;
loginRequest.password = password;
loginRequest.authenticationType = RKRequestAuthenticationTypeHTTPBasic;
loginRequest.method = RKRequestMethodPOST;
loginRequest.onDidLoadResponse = ^(RKResponse *response) {
// blabla
}
....sending request...
The first time I login, it just works. But if I do the same request again, I get a HTTP status code 405. When Im restarting my app, the next request works again. So I think it saves automatically some data like a session token or something internally. How can I reset this? Any hints?
Upvotes: 1
Views: 820
Reputation: 1454
It does indeed store any cookies (including session cookie) automatically from responses. To clear this, use the following:
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in cookieStorage.cookies)
{
[cookieStorage deleteCookie:cookie];
}
You can of course first inspect the cookies to see wether you want to delete them or not.
Upvotes: 4