0

Currently my non-visual crawl is built using NSUrlConnection. (I need to rewrite that to NSURlSession at some point.) My visual crawl/perform-login is built using WebView. (I am working on implementing support for WkWebView, but using Lazarus so a bit convoluted getting everything I need working.)

My use case is that I am using an embedded visual browser for login and having cookies set. I then want to continue crawling using the same session/everything/login/cookies using NSURLConnection/NSURLSession.

From my research it appears WkWebView is handling cookies much different from WebView/NSUrlConnection/NSURlSession and I will need to write some read/write cookies wrapper there. It seems WebView will automatically write to the within-app-shared-cookie-storage and those cookies are available at least within the app while the app runs.

Assuming that is correct: How can I use those cookies set by WebView (I will deal with WkWebView later) from within NSURLConnection and NSURLSession?

Tom
  • 3,587
  • 9
  • 69
  • 124

1 Answers1

0

IIRC, the default session ([NSURLSession sharedSession]) should use the shared cookie store by default, as should NSURLConnection.

If you're creating your own session, you should be able to specify [NSHTTPCookieStorage sharedCookieStorage] as the cookie store when creating the session configuration.

The exception would be if you're doing things in an app extension, in which case you might need to explicitly ask for the cookie storage of the main app or whatever.

dgatwood
  • 10,129
  • 1
  • 28
  • 49