0

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..

1 Answer 1

1

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
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.