Keeping user-data while running headless

165 views
Skip to first unread message

Mor Amrani

unread,
Nov 29, 2022, 5:59:39 PM11/29/22
to Chromium-dev
Hi,

Is there a way to persist user-data (such as cookies, local storage, indexedDB) while running Chromium in headless mode?

When running Chromium with the following flags:
Chromium --headless --user-data-dir="my-user-dir" --remote-debugging-port=9222 --disable-gpu https://www.google.com

The browsing session results in a partial version of the user data directory, which lacks Cookies and databases for example. In addition, some of the directories seem to be empty. This is the resulted structure:

ll my-user-dir/Default/

drwx------@ 3 user  staff   96 Nov 23 12:05 Cache
drwx------@ 4 user  staff  128 Nov 23 12:05 Code Cache
drwx------@ 7 user  staff  224 Nov 23 12:05 DawnCache
drwx------@ 7 user  staff  224 Nov 23 12:05 GPUCache
drwx------@ 3 user  staff   96 Nov 23 12:05 Local Storage
drwx------@ 7 user  staff  224 Nov 23 12:05 Session Storage
drwx------@ 3 user  staff   96 Nov 23 12:05 blob_storage


I'm running on MacOS 12.5

Thanks,
Mor

This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.

Mor Amrani

unread,
Dec 12, 2022, 5:59:07 PM12/12/22
to Chromium-dev, Mor Amrani
Update:
Seems like Local Storage and IndexedDB (and even Cookies on Linux machines) are persistent and available when using the default profile.
However, when creating new browser contexts using CDP Target.createBrowserContext method - none of the above exists and the browsing is similar to Incognito mode.

Is there a plan to support non-Incognito profiles in headless mode?

Thanks,
Mor
Reply all
Reply to author
Forward
0 new messages