Skip to content
Browse files

Allow logout by clearing the left-over cookies (fixes issue #35)

  • Loading branch information...
1 parent 37859a2 commit e39cedf6b8a3c34178f5bdd90475b2ddcc79222c @philippec committed May 1, 2012
Showing with 13 additions and 0 deletions.
  1. +10 −0 classes/PhFacebook.m
  2. +3 −0 private/PhFacebook_URLs.h
View
10 classes/PhFacebook.m
@@ -85,6 +85,16 @@ -(void) invalidateCachedToken
[defaults removeObjectForKey:kFBStoreAccessToken];
[defaults removeObjectForKey: kFBStoreTokenExpiry];
[defaults removeObjectForKey: kFBStoreAccessPermissions];
+
+ // Allow logout by clearing the left-over cookies (issue #35)
+ NSURL *facebookUrl = [NSURL URLWithString:kFBURL];
+ NSURL *facebookSecureUrl = [NSURL URLWithString:kFBSecureURL];
+
+ NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
+ NSArray *cookies = [[cookieStorage cookiesForURL: facebookUrl] arrayByAddingObjectsFromArray:[cookieStorage cookiesForURL: facebookSecureUrl]];
+
+ for (NSHTTPCookie *cookie in cookies)
+ [cookieStorage deleteCookie: cookie];
}
- (void) setAccessToken: (NSString*) accessToken expires: (NSTimeInterval) tokenExpires permissions: (NSString*) perms
View
3 private/PhFacebook_URLs.h
@@ -27,3 +27,6 @@
#define kFBGraphApiPostURL @"https://graph.facebook.com/%@"
#define kFBGraphApiFqlURL @"https://api.facebook.com/method/fql.query?query=%@&access_token=%@&format=json"
+
+#define kFBURL @"http://facebook.com"
+#define kFBSecureURL @"https://facebook.com"

0 comments on commit e39cedf

Please sign in to comment.
Something went wrong with that request. Please try again.