Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8013661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:41:37+00:00 2026-06-04T19:41:37+00:00

I am trying to take a cookie from NSHTTPCookieStorage and use it for another

  • 0

I am trying to take a cookie from NSHTTPCookieStorage and use it for another URL within my App. I am copying a cookie from NSHTTPCookieStorage and then setting the cookie for a different URL in NSHTTPCookieStorage using the copied cookie. I am trying to following code however when I print out the cookies for the other URL there are none.

    // authCookie is a cookie already in NSHTTPCookieStorage.
    NSURL *searchURL = [NSURL URLWithString:searchURLString];
    NSDictionary *authCookieProperties = [[[authCookie properties] copy] autorelease];
    NSMutableDictionary *cookieProperties = [NSMutableDictionary dictionaryWithDictionary:authCookieProperties];

    [cookieProperties setObject:searchURL forKey:NSHTTPCookieDomain];
    [cookieProperties setObject:searchURL forKey:NSHTTPCookieOriginURL];
    NSHTTPCookie *searchCookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
    [sharedHTTPCookieStorage setCookie:searchCookie];
    [sharedHTTPCookieStorage setCookies:[NSArray arrayWithObject:searchCookie] 
                                 forURL:searchURL 
                        mainDocumentURL:nil];

    NSLog(@"Cookies for search = %@", [sharedHTTPCookieStorage cookiesForURL:searchURL]);
    NSLog(@"All Cookies = ");
    NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (NSHTTPCookie *cookie in [cookieJar cookies]) {
        NSLog(@"%@", cookie);
    }
    /*
    Console Output (With URL and cookie values hidden):
    Cookies for search = ()
    All Cookies = 
    <NSHTTPCookie version:0 name:"auth_token" value:"COOKIEVALUE" expiresDate:(null) created:2001-01-01 00:00:01 +0000 (1) sessionOnly:TRUE domain:"<search_url>" path:"/" isSecure:FALSE>
    <NSHTTPCookie version:0 name:"auth_token" value:"COOKIEVALUE" expiresDate:(null) created:2012-05-14 17:59:36 +0000 (3.58711e+08) sessionOnly:TRUE domain:"<URL_of_auth_cookie>" path:"/" isSecure:FALSE>
    */
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:41:38+00:00Added an answer on June 4, 2026 at 7:41 pm

    You have to keep tab if the values that you are providing in the new cookie are good enough because as per the Apple reference, it is supposed to return nil if the initializing values are invalid in any particular way.
    You can further check this out at this link here. It has a rather nice way of creating a cookie from scratch!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to take data from three different tables and output it using as
I am trying to take the base URL from a site and be able
I'm trying to take values from a from and then and when it is
I am trying to take the values from the text fields below to use
I'm trying to take a photo from my iPhone app and upload to a
I'm trying to take an integer as a parameter and then use recursion to
Hello I'm trying to take backup from mysql command line client. I'm using mysqldump
I am trying to take information from a <tr> and prefill it in all
I'm trying to take the results of a view - using the function views_get_view_result()
I'm trying to take a screenshot of my Android application using Robotium, I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.