Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have multiple instances of webkit without sharing cookies?

Tags:

I have an app that creates a couple of WebView instances and I'd like to have them operate as independently as possible.

At the very least, I don't want them sharing cookies. A quick google search gave me results liking "you can't." I'm hoping someone has a better answer.

like image 861
Dustin Avatar asked Dec 12 '08 21:12

Dustin


1 Answers

The basic answer is "you can't".

After looking at this for a bit, I think it's possible, but extremely complicated. It would involve implementing a resourceLoadDelegate on your WebView that implements -webView:resource:willSendRequest:redirectResponse:fromDataSource: and modifies the request to turn off HTTPShouldHandleCookies and adds any relevant cookies to the request manually. It also has to implement -webView:resource:didReceiveResponse:fromDataSource: to find out about any cookies returned from the server. You can alloc/init your own copy of NSHTTPCookieStorage per-webview and use that to store/retrieve the cookies.

like image 196
Lily Ballard Avatar answered Sep 17 '22 01:09

Lily Ballard