Question

How do I keep a Puppeteer session logged in across runs?

Save the browser's cookies and local storage after signing in, restore them before the first navigation of the next run, and send that run from the same IP and timezone. Sites tie a session to more than its cookie, so a restored cookie arriving from a new address often gets signed out.

Last updated

Save the state, not just the cookie

In Playwright, `context.storageState()` writes cookies and local storage to a file and `browser.newContext({ storageState })` loads it. In Puppeteer, a persistent `userDataDir` keeps the whole profile, or you can read cookies with the DevTools protocol and write them back. Many apps keep part of the sign-in in local storage, so cookies alone are not always enough.

Restore it before the first page loads

Inject the saved state before the first navigation. A page that loads signed out may redirect to a sign-in form and overwrite the very cookies you were about to restore.

Come back from the same place

The common reason a restored session is rejected is the network, not the cookie. A session cookie that was issued to one IP and timezone and then replayed from a datacenter address in another reads as a stolen session. Reuse the same exit IP for each saved login, and keep the browser's timezone consistent with that IP.

With Scrappy

Capture a signed-in session as a saved login. The next session starts with it restored before the first page loads, from the same residential exit IP it was captured on, and a webhook tells you when a site ends the login.

Questions

Why does my restored session get logged out anyway?
Usually because it comes back from a different IP or timezone, or because only cookies were restored and the app also keeps sign-in state in local storage.
Can I try it before paying?
Yes. A new account gets 100 credits, enough for a few sessions of real use. A session costs 5 credits to start and 1 per minute after that.

Start

Try it on the site you need this week. The first 100 credits are free.

Enough for ten scrapes or a first hour in the cloud browser. No card, no call, no minimum.

The open webOne session away