WKWebView Persistent 1st-Party Cookie Deletion: Automatic Removal Policies in iOS/Safari

Our current iOS application utilizes WKWebView to display a web application. We've observed intermittent deletion of non-expired 1st-party persistent cookies within this web application, leading to session drops.

Here are our environment details and specific questions:

Environment:

App Build: Built with Xcode 16.2.

WebView Class: WKWebView.

Cookie Type: 1st-Party Persistent Cookie (Explicit expiration set, not a session cookie).

Domain Configuration: The content server and the cookie-issuing server are the same (same IP address, same eTLD+1). The Cookie is set via the Set-Cookie HTTP Header on the server side.

Questions:

Automatic Deletion Policy: Are there any scenarios (e.g., related to iOS system behavior, Safari policies, or Intelligent Tracking Prevention (ITP)) where iOS or Safari might automatically delete non-expired 1st-party persistent cookies used by WKWebView?

Deletion Conditions: If the answer to Q1 is Yes, under what specific conditions (e.g., memory pressure, inactivity, storage limits, specific ITP criteria) does this cookie deletion occur, and does the behavior differ significantly across various iOS versions?

OS Update Impact: Are there any known specifications or documented cases where an iOS version update itself triggers the mass deletion of existing cookies stored in the WKWebsiteDataStore?

Mitigation Strategy: If this automatic deletion is a known behavior, what mitigation strategies are officially recommended to ensure the persistence of essential 1st-party authentication cookies (e.g., manual synchronization with WKHTTPCookieStore or Keychain/UserDefaults)?

Official Documentation: If the answer to Q1 is Yes, please provide URLs to any official Apple documentation or technical notes that detail the specifications or behavior of 1st-party persistent cookie deletion within WKWebView.

We have also observed this issue in our application, where 1st-party persistent cookies in WKWebView are unexpectedly deleted approximately 1 to 4 weeks after creation, despite being within their set expiration period.

This behavior has been confirmed on iOS versions 18.5, 18.6, and 26.0.

If anyone has encountered similar symptoms or has information on possible workarounds, we would greatly appreciate your insights.

I think a good place to start here is to look at the various relevant standards for cookie handling (RFC 6265 and ensuing ietf specifications, for example) and if you find any out of bounds behavior file a bug so our engineering teams can investigate further.

If you file a bug report, include a small Xcode project and some directions that can be used to reproduce the problem, and post the Feedback number here once you do. If you post the Feedback number here I'll check the status next time I do a sweep of forums posts where I've suggested bug reports.

Bug Reporting: How and Why? has tips on creating your bug report.

WKWebView Persistent 1st-Party Cookie Deletion: Automatic Removal Policies in iOS/Safari
 
 
Q