Search code examples
ioscookiesuiwebviewwkwebviewsfsafariviewcontroller

Open iOS web view without cookies


If I have an iOS app, how can I open a browser view inside the app (upon the user tapping a button) which contains no cookies from any domains?

This means the browser view should not remember cookies from the previous time the user opened the browser, nor share cookies with the Safari app.

There are now three classes to do web views as far as I understand, SFSafariViewController, WKWebView and the dated UIWebView. Which of these allows what I want to achieve?


Solution

  • WKWebView is the way to go. Upon initialisation it won't contain any cookies from previous sessions. From the Apple documentation:

    Each web view is given its own Web Content process until an implementation-defined process limit is reached; after that, web views with the same process pool end up sharing Web Content processes.

    Furthermore, WKWebView is intended as a replacement for the older UIWebView.

    SFSafariViewController shares cookies and other website data with Safari.