Skip to content

[Feature]: Persist browser cookies/sessions across managed browser restarts (CDP cookie flush) #15645

Description

@malashenia

Feature Description

The OpenClaw managed browser (openclaw profile) loses all cookies and login sessions when the browser process restarts. Users must re-login to all services every time.

Root Cause

Chrome/Chromium controlled via CDP (Chrome DevTools Protocol) does not flush cookies to the SQLite database on disk. Cookies exist only in memory (document.cookie and Network.getAllCookies return them), but the Cookies file in user-data/Default/ remains empty (0 rows).

This is a known Chrome behavior when driven via CDP — confirmed in chromedp/chromedp#818.

Evidence

  • ~/.openclaw/browser/openclaw/user-data/Default/Cookies — SQLite DB exists but contains 0 rows
  • document.cookie in a running session returns valid cookies (e.g. GitHub sets _octo, tz, etc.)
  • After graceful browser stop (SIGTERM) — still 0 rows in Cookies DB
  • Session Storage and Local Storage files do update on disk — only Cookies are affected
  • Tested on Chrome 144.0.7559.133, macOS (Apple Silicon)

Proposed Solution

Implement cookie persistence via CDP API:

  1. On browser stop: Call Network.getAllCookies() via CDP → save to a JSON file (e.g. ~/.openclaw/browser/<profile>/cookies.json)
  2. On browser start: Read cookies.json → call Network.setCookies() to restore
  3. Periodic flush (optional): Every N minutes, save cookies to disk as a safety net

This would make the managed browser behave like a normal browser where login sessions survive restarts.

Workarounds (current)

  • Keep the managed browser running indefinitely (sessions survive as long as the process lives)
  • Use Chrome extension relay with the system browser (cookies persist naturally, but MV3 service worker timeout makes it unreliable)

Environment

  • OpenClaw version: 2026.2.6-3
  • OS: macOS 15.4 (Apple Silicon)
  • Browser: Chrome 144.0.7559.133
  • Profile: openclaw (managed, CDP port 18800)

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions