Questions tagged [nshttpcookie]

An NSHTTPCookie object represents an HTTP cookie. It’s an immutable object initialized from a dictionary containing the cookie attributes.

Two versions of cookies are supported:

  • Version 0: This version refers to “traditional” or “old-style” cookies, the original cookie format defined by Netscape. The majority of cookies encountered are in this format.
  • Version 1: This version refers to cookies as defined in RFC 2965, HTTP State Management Mechanism.
72 questions
5
votes
1 answer

Set a cookie in a iOS app and read that cookie from Safari

I'm trying to do the following: Inside my appDelegate I'm setting a cookie. After that I'm trying to read that cookie using JavaScript from a webapp. Is this possible? Because I can't make it work... This is my code in the iOS…
Andres
  • 10,201
  • 11
  • 45
  • 80
4
votes
2 answers

WKWebView pick cookies from NSHTTPCookieStorage

Does anyone know how to set a WKWebView to pick cookies from NSHTTPCookieStorage ? I tried injecting the cookie through WKUserScript, but it doesn't work since my page has several redirections, and every page in that redirection uses a cookie. Any…
4
votes
0 answers

WKWebView did't give all cookies in navigationResponse

I am trying to replace my working UIWebView project with WkWebView. I've seen many posts but i did't get any good solution for getting all cookies from WKWebView. I've also tried this evaluateJavaScript:@"document.cookie;" but it gives me this ().…
ZAFAR007
  • 2,545
  • 1
  • 26
  • 40
4
votes
1 answer

Set NSHTTPCookieExpires manually

I want to set a NSHTTPCookie in the NSHTTPCookieStorage. For doing that, I am creating a cookie & adding it to the NSHTTPCookieStorage as shown below:- NSDictionary *propertiesDevice = [NSDictionary dictionaryWithObjectsAndKeys: …
footyapps27
  • 3,746
  • 2
  • 22
  • 42
4
votes
1 answer

Why, after setting an NSHTTPCookie, is it not appended to the NSURLRequest?

I am setting (or attempting to set) an NSHTTPCookie as follows: + (void)setCookie { NSString* cookieName = @"MyCookieName"; NSString* cookieValue = @"MyCookieValue"; NSString* cookieOriginURL = @"www.mycompany.com"; NSString* cookiePath =…
Hap
  • 556
  • 1
  • 5
  • 20
4
votes
4 answers

failed create cookie with "NSHTTPCookie cookieWithProperties"

I use following code to create a cookie, but faild.(iOS SDK 5) // add cookie NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys: req.URL, NSHTTPCookieOriginURL, …
Galen Zhao
  • 127
  • 1
  • 8
3
votes
1 answer

How to listen for cookie being set in iOS NSHTTPCookieStorage?

I'd like to know when a cookie is set in NSHTTPCookieStorage. Is there an on change method or event handler? I'd like to prevent a cookie from being set.
Colin Whitmarsh
  • 326
  • 2
  • 8
3
votes
1 answer

Sync WKWebView Cookie to NSHTTPCookieStorage

WKWebView can manage its own cookie in WKHTTPCookieStorage, independent with NSHTTPCookieStorage. How can I sync cookie from WKHTTPCookieStore to NSHTTPCookieStorage. My target is sync the cookies with WKHTTPCookieStore and NSHTTPCookieStorage. I…
S.Captain
  • 167
  • 1
  • 9
3
votes
1 answer

Does WKWebView uses cookies from Safari?

According to Apple documentation: ... cookies are shared among all applications and are kept in sync across process boundaries. But there is this iOS Note: Cookies are not shared among applications in iOS. So basically I can not use cookies from…
Xernox
  • 1,587
  • 1
  • 19
  • 32
3
votes
3 answers

Accessing session cookies with NSHTTPCookieStorage

I'm accessing a server's secure information and it sends a bunch of cookies to the App on request. The problem is some of the cookies are session only and when I use: [NSHTTPCookie requestHeaderFieldsWithCookies:[[NSHTTPCookieStorage…
Rudiger
  • 6,515
  • 13
  • 48
  • 94
3
votes
1 answer

NSHTTPCookieStorage Vs keychain vs NSUserdefault

iOS : NSHTTPCookieStorage, Keychain, NSUserDefault between these three, what is the best place to store token on device? and why? Note: I don't want to share token with any other app or Safari/browser.
3
votes
2 answers

iOS: how to set httponly flag for NSHTTPCookie

I am using the following code to construct NSHTTPCookie But there is no options to set httpOnly flag for cookie [cookieProperties setObject:@"name" forKey:NSHTTPCookieName]; [cookieProperties setObject:@"value"…
hariszaman
  • 7,457
  • 2
  • 35
  • 53
3
votes
1 answer

Google Reader API with Objective-C - Problem getting token

I am able to successfully get the SID (SessionID) for my Google Reader account. In order to obtain the feed and do other operations inside Google Reader, you have to obtain an authorization token. I'm having trouble doing this. Can someone shed…
Justin
  • 9,042
  • 7
  • 67
  • 97
3
votes
1 answer

NSHTTPCookieStorage does not save cookie automatically

I'm recieving cookie in Set-Cookie header of NSURLResponse, but [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies] returns empty list. NSHTTPCookie, which i received from response, is HTTPOnly, secure and has no expiresDate. What can be reason…
3
votes
0 answers

Unit testing NSHTTPCookieStore

In my iPhone App, to logout my client I need to delete the cookies for a given URL. It's easy to code and @matt from AFNetworking gave a simple code example to do so. - (void)cleanCookies { NSArray *cookies = [[NSHTTPCookieStorage…