objective c - not deleting cookie (iphone) -
nshttpcookiestorage *storage = [nshttpcookiestorage sharedhttpcookiestorage]; nsarray *cookies = [storage cookiesforurl:[nsurl urlwithstring:@"http://www.facebook.com/"]]; nslog(@"old cookies!: %@",cookies); nshttpcookie *cookie; (cookie in [storage cookies]) { [storage deletecookie:cookie]; } nslog(@"new cookies!: %@",cookies);
i trying delete facebook cookie in logout function no cookies deleted. not understand why. appreciated.
if want changes nshttpcookiestorage retained, you'll want synchronize standarduserdefaults after modifying cookie store:
[[nsuserdefaults standarduserdefaults] synchronize];
to prevent slowing down app, may want call on background thread so:
dispatch_queue_t backgroundqueue = dispatch_get_global_queue(dispatch_queue_priority_background, 0); dispatch_async(backgroundqueue, ^{ //todo: cookie deletion logic here });
edit:
if need disregard cookies altogether given nsurlrequest, can with:
[request sethttpshouldhandlecookies:no];
where request instance of nsurlrequest.
Comments
Post a Comment