Skip to content

Cookies fail to persist/store after clear_cookies() call or session reset #1765

@MarketingPip

Description

@MarketingPip

Bug Report: clear_cookies() prevents future cookie persistence in storage_path

Description

After calling window.clear_cookies() or expiring a cookie via a server-side logout, the webview engine appears to stop persisting cookies to the defined storage_path. Even if the user logs back in successfully, cookies are no longer written to disk and are lost upon application restart.

Environment Details

  • OS: Windows 7
  • pywebview Version: 5.0
  • Python Version: 3.7
  • Renderer: Default for Win7

Steps to Reproduce

  1. Initialize webview.start(storage_path='PATH_TO_DIR', private_mode=False).
  2. Log in to the application (Cookie is successfully stored and persists across restarts).
  3. Trigger a logout that performs two actions:
    • Server-side: Set-Cookie header with an expired date.
    • Client-side (Python): window.clear_cookies().
  4. Log back into the application.
  5. Close the application and restart.

Observed Behavior

  • After the "clear" event, the cookie jar seems to "lock."
  • Subsequent cookies generated during the session are visible in DevTools in a normal browser client but are not written to the storage_path.
  • On restart, the user is unauthenticated because the storage_path was not updated.

Expected Behavior

clear_cookies() should empty the current session and disk storage, but allow the engine to continue writing new cookies to the storage_path for the remainder of the session.

Additional Context

It appears the webview engine stops syncing the in-memory cookie jar to the persistent storage once a manual clear command is issued. This was tested with private_mode=False.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions