【发布时间】:2019-12-12 04:06:14
【问题描述】:
我这样设置HTTPCookieStorage:
let storage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: "user100")
storage.cookieAcceptPolicy = .always
let cookieProperties: [HTTPCookiePropertyKey : Any] = [.name : "example\(Date().timeIntervalSince1970)",
.value : "value\(Date().timeIntervalSince1970)",
.domain : "www.example\([100,200,300].randomElement()!).com",
.originURL : "www.example.com",
.path : "/",
.version : "0",
.expires : Date().addingTimeInterval(2629743)
]
storage.setCookie(HTTPCookie(properties: cookieProperties)!)
我发现对 HTTPCookieStorage.shared 执行相同操作实际上可以保存 cookie,而这个自定义 HTTPCookieStorage 不是。如何让它持久化?
【问题讨论】:
标签: swift uikit httpcookie nshttpcookiestorage