Skip to content

Commit

Permalink
Merge pull request #22 from p-x9/feature/sync-http-cookie-storage
Browse files Browse the repository at this point in the history
fix to export http cookies before stashing container
  • Loading branch information
p-x9 committed Oct 7, 2022
2 parents c4f4e90 + c58caff commit 24b5a60
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Sources/AppContainer/AppContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class AppContainer {
}

try exportUserDefaults()
exportCookies()

try stash()

Expand Down Expand Up @@ -443,5 +444,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"))
}
}

0 comments on commit 24b5a60

Please sign in to comment.