← Back to discussions

WKWebView keeps clearing cookies randomly. Anyone else?

NNoopurPublished 6/21/2026429 views1 comments

On iOS 16 and 17, our WKWebView app keeps logging users out randomly. It seems the WKHTTPCookieStore clears the cookies or doesn't sync them back to disk between app restarts.

Has anyone found a reliable way to make iOS persist session cookies on disk?

1 Comments

SSia Singh6/21/2026

WKWebView is notorious for this. The best workaround is to store your auth session token in localStorage or sessionStorage on the frontend, and have a small script restore the cookie from storage if it detects the cookie has disappeared. WKWebView doesn't clear localStorage nearly as aggressively as it clears cookies.

Please log in to reply.
WhatsApp