Separate cookies for multiple WKWebViews in one app

I have 2 WKWebViews in my app. They have different process pools and different configurations. I login to mail.google.com on one of them. I open mail.google.com on the other. It should not auto login to the gmail account, but it does. AFAIK, having different process pools for the webviews should solve this problem. But it doesn't? What am I missing?


I am using Xcode 7.3.1 and iOS 9.3.

//Global variables
//
//Note: using anything else than non-persistent will not work
////////////////////////////////////////////////////////////////////////////////
let websiteDataStoreA = WKWebsiteDataStore.nonPersistent()
let websiteDataStoreB = WKWebsiteDataStore.nonPersistent()

let processPoolA = WKProcessPool() //May not be needed
let processPoolB = WKProcessPool() //May not be needed

let useWebsiteDataStoreA = true

//Extend WKWebView : Maybe there is another way, but I have read that
//                   websiteDataStore must be selected in the init() and
//                   not after.
////////////////////////////////////////////////////////////////////////////////
class myWeb: WKWebview {

    init() {

        let configuration = WKWebViewConfiguration()

        //Choose your cookie jar (and many other things)
        ////////////////////////////////////////////////
        if useWebsiteDataStoreA {

            configuration.websiteDataStore = websiteDataStoreA
            configuration.processPool = processPoolA //May not be needed
        }
        else {

            configuration.websiteDataStore = websiteDataStoreB
            configuration.processPool = processPoolB //May not be needed
        }

        super.init(frame: CGRect(x: 0, y: 0, width: 512, height: 512),
                   configuration: configuration)
    }
}

How do you save cookies?

Separate cookies for multiple WKWebViews in one app
 
 
Q