If your web application uses url sessions, you can save your current url using the webview delegate:
- (void)webViewDidFinishLoad:(UIWebView *)myWebView { NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:myWebView.request.URL.absoluteString forKey:@"lastUrl"]; [prefs synchronize]; }
... and load it again from the settings when viewDidLoad:
- (void)viewDidLoad { [super viewDidLoad]; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [webView loadRequest: [NSURLRequest requestWithURL: [NSURL URLWithString: [prefs objectForKey:@"lastUrl"]]]]; }
You can also access cookies with javascript if you need to save and set them:
NSString *myCookies = [[myWebView stringByEvaluatingJavaScriptFromString:@"document.cookie"] copy];
source share