If an Electron cookie arrives as unspecified and your Playwright code changes it to Lax, that conversion may be losing information. Electron documents unspecified, no_restriction, lax and strict; Playwright documents Strict, Lax and None. Neither API’s documentation defines a universal conversion for Electron’s unmatched values. Don’t assume the mapping caused a logout: make the conversion policy explicit, then check the rest of the cookie and which session or browser context received it.
Why “unspecified” does not automatically mean “Lax”
Electron and Playwright expose different sets of values for a cookie’s sameSite attribute. Electron’s Cookie Object documentation lists unspecified, no_restriction, lax and strict. Playwright’s BrowserContext cookie APIs document Strict, Lax and None.
The documented vocabularies overlap for lax/Lax and strict/Strict, allowing a casing normalization for those recognized values. But the cited API documentation does not prescribe how to convert Electron’s unspecified or no_restriction into Playwright’s vocabulary. It does not establish that either value means Lax or None in every transfer scenario. A direct substitution is a policy choice, not a documented equivalence.
That mismatch is a reasonable place to investigate when authentication breaks, but it does not prove why a particular user was logged out. Treat an unmatched value explicitly: preserve it in your intermediate record, choose a fallback only if your application’s requirements justify it, and test the result against the target behavior. If the destination cannot represent the source value, record that limitation rather than silently presenting the fallback as an exact translation.
#1 Best Overall
Compare the whole cookie, not just sameSite
A cookie may be rejected, sent to the wrong requests, expire sooner than expected or be installed in the wrong place for reasons beyond sameSite. Compare the complete record before and after serialization. Electron’s documented cookie object includes fields such as hostOnly, session and expirationDate; Playwright’s cookie APIs use their own input shape.
- Identity and scope: compare the name, value, domain and path. Playwright’s cookie API requires a
url, or bothdomainandpath, when adding a cookie. Check whether an Electron host-only cookie remains restricted to its host instead of being broadened into a domain cookie. - Transmission flags: compare
secureandhttpOnly. Do not assume a conversion that copies only name, value andsameSitehas preserved these attributes. - Lifetime: distinguish a session cookie from one with an expiry. Electron documents
sessionandexpirationDate; verify that your conversion does not turn a session cookie into a persistent one, or discard an expiry that the target needs. - Same-site value: normalize casing only for values both APIs name. For
unspecifiedandno_restriction, apply a deliberate, documented fallback—or stop and flag the unsupported source value.
Playwright’s storage-state documentation covers cookies and origins, and its documented cookie same-site vocabulary remains Strict, Lax and None. Inspect the complete saved record rather than treating a successful JSON serialization as proof that every Electron distinction survived.
Rank #2
Verify the cookie jar and session are the expected ones
Even a correctly formed cookie will not authenticate a request if it is added to a different context or session from the one making the request. Playwright browser contexts isolate cookies and other storage, while Electron’s session API supports persistent and in-memory partitions. Electron partitions with a persist: prefix are persistent; sessions without that prefix are in memory.
- Confirm which Electron session produced the cookie and which Playwright browser context is consuming it.
- Check whether the Electron partition is persistent or in memory, and whether the Playwright test creates a fresh isolated context.
- Verify that the cookie was added to the context used for the authenticated navigation or request, not merely to another context in the same test run.
- When saving or loading Playwright storage state, confirm that the state file is the one associated with the context under test and that it contains the expected cookie and origin data.
A cookie copied to a fresh in-memory session or the wrong isolated context can look like a same-site conversion failure. These checks follow from the documented session and context models; they do not diagnose the cause of any particular logout.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchUse a conversion policy that makes data loss visible
Keep the source value available until your code has made its conversion decision. This avoids accidentally treating a fallback as though it were the original value and makes logs useful when a test fails.
- Read the source value as received. Record the original Electron
sameSitestring alongside the cookie’s other attributes. - Normalize only recognized matches. Convert Electron
laxandstrictto the corresponding Playwright values if that casing adjustment is all your conversion needs. - Handle unmatched values deliberately. For
unspecifiedorno_restriction, apply a fallback chosen for the application’s requirements, or reject the conversion and surface the unsupported value. The official APIs do not supply a universal mapping. - Compare the serialized result. Check scope, flags and lifetime as well as
sameSite; ensure Playwright receives its required URL or domain-and-path information. - Test the actual target setup. Reproduce the relevant authenticated flow using the Electron and Playwright versions in your project, with the intended session and context arrangement.
What to capture when the logout persists
For a reproducible report, include the actual Electron and Playwright versions, the original and converted cookie records with secrets redacted, the conversion rule used for unmatched values, and the session or context in which the cookie was installed. Also describe the request or navigation that fails. The cited documentation describes API shapes, not a release-specific guarantee for every cross-runtime transfer; version details help distinguish an application-level mapping choice from setup-specific behavior. Playwright describes its Electron automation support as experimental, so avoid treating behavior outside the documented API contract as guaranteed.
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

