Search code examples
iphoneiossessiontumblrlogout

How to "flush" Objective-C HTTP session IDs? (Force logout from tumblr)


I made a Tumblr Oauth API, and implemented an unlink function for the user. The only problem that Tumblr still remain logged in.

I want to reset the session somehow. I've heard that session IDs are handled somewhere automatically by Cocoa.


Solution

  • Chances are the session id is stored in a cookie. Use NSHTTPCookieStorage class to remove it:

        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
    

    You can find the cookie for the session id by using

        NSArray *allCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
    

    and iterating the allCookies array looking for the matching domain and path values.