diff --git a/Sources/AppContainer/AppContainer.swift b/Sources/AppContainer/AppContainer.swift index 673e2f2..4c843f9 100644 --- a/Sources/AppContainer/AppContainer.swift +++ b/Sources/AppContainer/AppContainer.swift @@ -99,6 +99,7 @@ public class AppContainer { } try exportUserDefaults() + exportCookies() try stash() @@ -438,5 +439,16 @@ extension AppContainer { let plistData = try PropertyListSerialization.data(fromPropertyList: dictionary, format: .xml, options: 0) try plistData.write(to: plistUrl) } - +} + +extension AppContainer { + private func exportCookies() { + let cookieStorage: HTTPCookieStorage + if let groupIdentifier = groupIdentifier { + cookieStorage = HTTPCookieStorage.sharedCookieStorage(forGroupContainerIdentifier: groupIdentifier) + } else { + cookieStorage = .shared + } + cookieStorage.perform(NSSelectorFromString("_saveCookies")) + } }