playwright icon indicating copy to clipboard operation
playwright copied to clipboard

Chrome headless (persistent) doesn't save/load cookies on windows

Open JoelEinbinder opened this issue 6 years ago • 18 comments

On Windows, headless chrome can't read cookies from a userdatadir. It is specific to cookies, localStorage works. The Default\Cookies file exists, and is a valid SQLite table, but it has no rows. Launching with headful, I can see the cookie in the SQLite file, but launching headless chrome afterwards clears the file again, and doesn't read the cookie.

Possibly related to, Puppeteer/Puppeteer#4111, but where that was flaky, this is consistently broken.

#680

JoelEinbinder avatar Jan 28 '20 20:01 JoelEinbinder

Confirmed, my problem is the same. Take hours to figure this because it works fine on my Ubuntu machine.

meotimdihia avatar Feb 27 '20 04:02 meotimdihia

i though i was going crazy, i am on win10 same problem headless true cookies don't get restored with it false it works fine, is there a workaround?

emko avatar Apr 13 '20 08:04 emko

We need a solution for this issue please

sameh81 avatar Jun 20 '20 00:06 sameh81

Hello guys. Still face it on Version 86.0.4240.75 (Official Build) (64-bit) for Windows 10.

kajojify avatar Oct 08 '20 23:10 kajojify

Confirmed, my problem is the same. Take hours to figure this because it works fine on my Ubuntu machine.

@meotimdihia maybe you just got lucky on Ubuntu with an older version of Chromium installed? I cannot get cookies from my —user-data-dir on either Windows or Ubuntu to work when in headless mode.

ctataryn avatar Oct 11 '20 02:10 ctataryn

Same issue on headless Ubuntu Bionic, but with Webkit. The browser context has no cookie, won't set them after receiving a Set-Cookie header response, and I can't set them manually neither.

guifry avatar Nov 25 '20 15:11 guifry

I'm also experiencing this and it's a bit frustrating :D

On Linux/MacOS, I do see that it stores session storage is created with headless mode. However on Windows 10, there's like 1 file in the 'user-dir' folder I specify.

Not sure if anyone has a workaround, if I find one I'll try to post it here.

Proryanator avatar Apr 14 '21 15:04 Proryanator

Seeing the same issue but on MacOS. Most cookies persisted except for one. Everything runs fine with headless: false.

rjzheng avatar Jul 15 '21 11:07 rjzheng

Same on MacOS

sergioariveros avatar Aug 03 '21 23:08 sergioariveros

Why was this issue closed?

We are prioritizing the bugs based on the upvotes, recency and our ability to act. It looks like this issue only has a handful of upvotes, has not been touched recently and/or we lack sufficient feedback to act on it. We are closing issues like this one to keep our bug database maintainable. Please feel free to open a new issue and link this one to it if you think this is a mistake.

pavelfeldman avatar Jan 06 '22 18:01 pavelfeldman

I'm also facing same issue on mac (local) and ubuntu (CI)

syedasadulhaq avatar Jan 13 '22 12:01 syedasadulhaq

Still having the same issue on Mac with Chrome Version 98.0.4758.80 (Official Build) (x86_64)

ghost avatar Feb 11 '22 19:02 ghost

Still experiencing this issue, Chrome 100.0.4896.127 on Windows 10. Is there ever going to be a fix for this?

twilight-sparkle-irl avatar May 04 '22 17:05 twilight-sparkle-irl

Cookies are missing when running playwright with headless mode enabled. Happened at Chrome 103.0.5060.114 on macOS Big Sur Version 11.6 with M1 Chip.

pawlarius avatar Jul 08 '22 04:07 pawlarius

I confirm this very problem on Mac. I run with --user-data-dir and when I run in --headless mode, the cookies saved from previous runs are not loaded. When I disable --headless, the cookies load normally. Google Chrome 106.0.5249.103

The only way is to save cookies into a file manually after every page load, and then load that file manually on next init.

ethaniel avatar Oct 11 '22 14:10 ethaniel

Any solutions to this? Still having the same problem, set-cookies header is missing on the response.

AlizerUncaged avatar Jan 02 '23 08:01 AlizerUncaged

Here, cookies do not load if the browser is in --headless mode.

SantiiRepair avatar Nov 02 '24 17:11 SantiiRepair

Same here, cookies do not load if browser is in --headless mode. We need a solution for this.

phuctm97 avatar Nov 11 '24 08:11 phuctm97