WKWebView changing cookie version to 1

When I take a cookie and add it to a WKWebView's httpCookieStore, the cookie's version suddenly changes from 0 to 1.


Is this a bug, or is there some actual reason this should happen?


It's easily reproducible in Playgrounds like this:


import WebKit
import PlaygroundSupport
let cookie = HTTPCookie(properties: [.path: "/", .name: "foo", .value: "bar", .domain: "foobar.com", .version: 0])!
let webView = WKWebView()
print("My cookie is named \(cookie.name) and its version is \(cookie.version)")
webView.configuration.websiteDataStore.httpCookieStore.setCookie(cookie) {
    webView.configuration.websiteDataStore.httpCookieStore.getAllCookies { cookies in
        let transferredCookie = cookies.first!
        print("Transferred cookie is named \(transferredCookie.name) and its version is \(transferredCookie.version)")
    }
}
PlaygroundPage.current.needsIndefiniteExecution = true


The output is this:


My cookie is named foo and its version is 0

Transferred cookie is named foo and its version is 1

That’s certainly odd. If this behaving is causing you grief I encourage you to file a bug report with an explanation of the problem.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks, submitted! Radar id for the record is 37351325

WKWebView changing cookie version to 1
 
 
Q