Skip to content

[Bug]: CapacitorCookies does not respect subsequent response Set-Cookie headers on iOS #7968

Closed

Description

@SaebAmini

Capacitor Version

Capacitor Doctor

Latest Dependencies:

@capacitor/cli: 7.2.0
@capacitor/core: 7.2.0
@capacitor/android: 7.2.0
@capacitor/ios: 7.2.0

Installed Dependencies:

@capacitor/cli: 7.2.0
@capacitor/android: 7.2.0
@capacitor/core: 7.2.0
@capacitor/ios: 7.2.0

Other API Details

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

After enabling CapacitorCookies, I'm observing this faulty behaviour with cookie handling on iOS devices:

  • When the response first returns a Set-Cookie header, it is persisted correctly (verified that it shows up under Safari Storage > Cookies when inspected).
  • Subsequent server responses returning a Set-Cookie for the same cookie, are ignored and the persisted cookie doesn't update. This results in the old stale cookie being sent back to the server on subsequent requests.

Some of the scenarios this issue blocks:

  • Server simply wanting to clear a cookie (e.g. common on logging out). Currently the cookie persists.
  • If the user signs in with another account it keeps sending the previous user's cookie.
  • Server wanting to update the cookie as a result of updated claims etc., or simply updating the expiry date.

Other notes:

  • This doesn't happen on an Android device based on my testing, so seems to be a bug just on the iOS implementation.
  • This behaviour doesn't happen with the normal "unpatched" document.cookie (i.e. when not having CapacitorCookies enabled)
  • When I manually delete the cookie, then the subsequent responses with Set-Cookie are properly processed. This leads me to believe there is a bug in the iOS implementation somewhere that cannot handle an existing cookie.

Expected Behavior

Every Set-Cookie header should be processed, and update existing cookie if one exists.

Project Reproduction

Can provide later if absolutely necessary, but the explanation is clear.

Additional Information

No response

Activity

  1. SaebAmini commented on Apr 9, 2025

    @SaebAmini
    Author

    Reading #7262, I think the issues could be because of the same root cause.

  2. davidbeaton commented on Apr 16, 2025

    @davidbeaton

    We also have been seeing this issue for quite some time and have had to work around it in a not ideal way that we would eventually like to remove. I opened #6591 a few years ago which appears to be the same root cause as this new opened issue

    #6591

  3. eric-horodyski commented on Feb 24, 2026

    @eric-horodyski
    Member

    We’re reviewing older issues as part of our backlog cleanup effort:
    https://ionic.io/blog/keeping-capacitors-backlog-healthy

    To keep this open, please provide an updated minimal reproduction and environment details on the latest version of Capacitor within 7 days.

    Otherwise, we’ll close it to keep the backlog focused. It can always be reopened with updated info.

  4. added
    needs replyneeds reply from the user
    and removed
    needs replyneeds reply from the user
    on Feb 24, 2026
  5. Ionitron commented on Sep 9, 2026

    @Ionitron
    Collaborator

    It looks like this issue didn't get the information it needed, so I'll close it for now. If I made a mistake, sorry! I am just a bot.

    Have a great day!
    Ionitron 💙

  6. ionitron-bot commented on Oct 9, 2026

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

  7. locked and limited conversation to collaborators on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs reproductionneeds reproducible example to illustrate the issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions