Reputation: 3945
I want to set session and store values like cookies in the web browser in iPhone App. Is it possible? How can I implement this in iPhone? Can any one suggest a good solution..
Upvotes: 0
Views: 485
Reputation: 6427
Just set cookies like
NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSHTTPCookie* testCookie = [NSHTTPCookie cookieWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
@"1", NSHTTPCookieValue,
@"test_cookie", NSHTTPCookieName,
@".facebook.com", NSHTTPCookieDomain,
@"/", NSHTTPCookiePath,
nil]];
[cookies setCookie:testCookie];
And Get the cookies like
NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie* cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
//here you can get you specific cookies
}
Upvotes: 1