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 1057261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:50:23+00:00 2026-05-16T17:50:23+00:00

My iPhone app has a UIWebView that loads a page containing javascript that sets

  • 0

My iPhone app has a UIWebView that loads a page containing javascript that sets a cookie. It seems that if i set a cookie and exit the app within 10-15 seconds then the cookie is never saved, however if i set the cookie, wait 10-15 seconds THEN exit the app, the cookie is saved.

Anyone have any info about why their is a delay and how to go about having the cookies saved immediately.

  • 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-05-16T17:50:24+00:00Added an answer on May 16, 2026 at 5:50 pm

    The only workaround i was able to come up with is to save the cookies to the user defaults right before the app terminates. When the app is opened, go through the user defaults, pull out the cookies, and rewrite them to the cookie storage. It works but if your app is forcefully terminated then it doesnt really.

    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
        cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
        [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
    
        // Load the saved cookies
        NSDate *currentDate = [NSDate date];
        NSTimeInterval expirationAmount = 5 * 365 * 24 * 60 * 60;
        NSDate *expirationDate = [currentDate dateByAddingTimeInterval:expirationAmount];
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        for (id theKey in [defaults dictionaryRepresentation]) {
            if ([theKey hasPrefix:@"cookie:"]) {
                [self setCookie:[theKey substringFromIndex:7] value:[defaults objectForKey:theKey] expiration:[expirationDate description] domain:urlDomain];
            }
        }
    }
    
    - (void)applicationWillTerminate:(UIApplication *)application {
      // Save the cookies to the user defaults
      NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
      NSArray* theCookies = [cookieStorage cookies];
     for(NSHTTPCookie *myStr in theCookies) {
        [defaults setValue:[myStr value] forKey:[NSString stringWithFormat:@"cookie:%@", [myStr name]]];
         }
         [[NSUserDefaults standardUserDefaults] synchronize];
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 540k
  • Answers 540k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just one example: In C++ there is no difference between… May 17, 2026 at 2:31 am
  • Editorial Team
    Editorial Team added an answer Your going about this backwards. First of all, you don't… May 17, 2026 at 2:31 am
  • Editorial Team
    Editorial Team added an answer Here is an example: #include <stdlib.h> #include <stdarg.h> #include <stdio.h>… May 17, 2026 at 2:31 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Let's say I have an iPhone app that has a UIWebView. Is it possible
I'm currently making an iPhone app that has PDF viewing a crucial part of
I'm working on an iPhone app that has a UITabBar. Occasionally the tab bar
I have a regular old iPhone app that has a main view controller that
In my iPhone app, I have a UIWebView where I'm loading a local html.
For an iPhone app, I'm working on a feature that allows users to make
In my iPhone app, I have this button, that opens a webcal:// URL in
I have to make an iPhone app for a company which has a web
Ok I want to keep track of how many times my iPhone App has
i'm currently working on iphone app which has a web view. i'm pulling a

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.