NSHTTPCookieStorage to implement "Sign Out" functionality
NSHTTPCookieStorage to implement "Sign Out" functionality
- Subject: NSHTTPCookieStorage to implement "Sign Out" functionality
- From: Jesse Grosjean <email@hidden>
- Date: Tue, 1 Dec 2009 18:29:13 -0500
My desktop app connects to a web application that's hosted on Google
App engine. Once it authenticates it gets a cookie that it passes
along for all future requests. That all works.
But now I want to add "Sign out". That feature code looks like this:
- (void)signOut {
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage
sharedHTTPCookieStorage];
for (NSHTTPCookie *each in [[[cookieStorage cookiesForURL:[NSURL
URLWithString:self.serviceRootURLString]] copy] autorelease]) {
[cookieStorage deleteCookie:each];
}
}
But it only seems to work the first time. For instance I can open my
app. Sign in. Make some requests. Sign out. Then next time I make a
request I'm asked to authenticate again. Good!
But after I authenticate the second time the problem happens. The
authentication works. I get the cookie. I can make requests. But then
when I try to log out for the second time (without restarting my app)
the cookies don't seem to get deleted. They do seem deleted from my
apps perspective... ie I ask the cookie store for the cookies that it
has for that URL and it returns none. But if I try to make another
request (that should require a cookie) the request just works, I'm
never asked to authenticate again.
So if I'm understanding things correctly it seems that the cookies are
deleted from my perspective, but they are not deleted from the
underlying URL loading frameworks prespective.
Of possible interest:
- Could the problem be related to:
http://www.macworld.com/article/143343/2009/10/safaricookieproblems.html
Does anyone know how to consistently implement "log out" functionality
in an app that interacts with a web service?
Thanks,
Jesse
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden