• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Sending Cookies in NSMutableURLRequest
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sending Cookies in NSMutableURLRequest


  • Subject: Sending Cookies in NSMutableURLRequest
  • From: Jerry Krinock <email@hidden>
  • Date: Mon, 12 Sep 2011 15:12:10 -0700

When I send message -setHTTPShouldHandleCookies:YES to an NSMutableURLRequest, does that mean that it will search in -[[NSHTTPCookieStorage sharedHTTPCookieStorage], find all the cookies that are qualified by domain and path, and send them when in an NSURLConnection created with this request?

If so, I'm not getting expected results.  Is there a way to see the cookies that are actually being sent?  Cookies don't seem to show in -allHTTPHeaders, and I cannot see them in tcpdump either if using SSL (https).

If not, what is the correct way to add cookies to a request?  I've tried the following code, to generate the value of a "Cookie: " string in the Netscape format:

// cookies is a dictionary of cookies I want to send in request

NSMutableString* cookieString = nil ;
for (NSString* cookieName in cookies) {
    NSString* value = [[cookies objectForKey:cookieName] value] ;
    if (!cookieString) {
        cookieString = [NSMutableString string] ;
    }
    else {
        [cookieString appendString:@";"] ;
    }

    [cookieString appendFormat:@"%@=%@", cookieName, value] ;
}

// At this point, cookieString is, for example:
//    "name1=value1;name2=value2"

[mutableRequest setValue:cookieString
      forHTTPHeaderField:@"Cookie"] ;

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Sending Cookies in NSMutableURLRequest
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Prev by Date: Re: CFMessagePortCreateRemote, launchd, Bootstrap Namespace, 10.5
  • Next by Date: Re: Sending Cookies in NSMutableURLRequest
  • Previous by thread: Re: CFMessagePortCreateRemote, launchd, Bootstrap Namespace, 10.5
  • Next by thread: Re: Sending Cookies in NSMutableURLRequest
  • Index(es):
    • Date
    • Thread