Skip to content

Instantly share code, notes, and snippets.

Created December 17, 2010 05:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Mac OS X cookie dumper (for
#import <stdio.h>
#import <Foundation/NSHTTPCookieStorage.h>
#import <Foundation/NSHTTPCookie.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSEnumerator.h>
int main( int argc, const char* argv[] ) {
NSURL *url = [[NSURL alloc] initWithString: @""];
NSArray* cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url];
printf( "%lu cookies found\n", [cookies count] );
NSEnumerator* i = [cookies objectEnumerator];
id obj;
while (obj = [i nextObject]) {
if ([obj isMemberOfClass: [NSHTTPCookie class]] == YES) {
const char* name = [[obj name] UTF8String];
const char* value = [[obj value] UTF8String];
printf( "cookie: [%s]=[%s]\n", name, value );
printf( "all done\n" );
return 0;
// to make:
// gcc test.m /System/Library/Frameworks/Foundation.framework/Versions/Current/Foundation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment