---
title: "How to Keep Browser Cookies Fresh: Fix Logins That Expire"
description: "Logging out again? Learn how to keep browser cookies fresh: skip clear-on-exit, use accounts often, isolate each identity. Expired sessions need a new login."
url: "https://donutbrowser.com/ja/keep-browser-cookies-fresh/"
---

1. [ホーム](https://donutbrowser.com/ja/)

2. [ブログ](https://donutbrowser.com/ja/blog)

3. How to Keep Browser Cookies Fresh: Fix Logins That Expire

# How to Keep Browser Cookies Fresh: Fix Logins That Expire

October 31, 2026

browser cookies login sessions cookie backup

**Here is how to keep browser cookies fresh: keep persistent cookies (no clear-on-exit, no ephemeral windows), use each account often enough to beat the server’s idle timeout, and give each identity its own isolated cookie jar. No browser setting can revive a session the server has expired or revoked, so sometimes logging in again is the only fix.**

A login that worked on Friday asks for a password on Monday. Social media managers, sellers in several regions, QA and automation engineers and privacy-minded users hit this most, because every extra account is another session that can expire.

This guide shows how to keep browser cookies fresh: you will find why a session ended, fix the setting behind it, back up before cleanup, and keep several identities logged in safely.

> **Key Takeaways**

> - [Chrome caps cookie lifetime](https://developer.chrome.com/blog/cookie-max-age-expires) at 400 days, and [Safari caps script-written storage](https://webkit.org/tracking-prevention/) at seven days, so a far-off Expires date promises little.

> - An exported cookie file works like a password: [Lifehacker notes](https://lifehacker.com/tech/best-privacy-hacks-browser-cookies) a stolen session cookie can log in without one. Encrypt it.

> - Cleaning up site by site, after a cookie export, keeps the logins you rely on.

> - [Playwright’s `storageState`](https://playwright.dev/docs/auth) persists login state between automated runs.

## Why do browser cookies go stale before you expect?

Browser cookies go stale because session cookies disappear when the browser closes, persistent cookies end at their Expires or Max-Age date, and the server can end a session even while the cookie looks valid.

[MDN’s guide to HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) separates the two kinds: session cookies are deleted when the current session ends, while permanent cookies are deleted at the date set by Expires or after the period set by Max-Age.

MDN adds that some browsers restore sessions on restart, so a session cookie can sometimes last much longer than you’d expect.

[RFC 6265](https://datatracker.ietf.org/doc/html/rfc6265) defines the two date attributes. Expires is a calendar date and time, and Max-Age is a number of seconds. If both are present, the RFC says “the Max-Age attribute has precedence and controls the expiration date of the cookie.”

Two more attributes affect logins. HttpOnly keeps scripts from reading the cookie, and SameSite, defined in the [RFC 6265bis draft](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis), limits the cookie to requests that are same-site.

A login cookie with a strict SameSite value may not be sent when you arrive from another site.

Suppose a site sets a login cookie with a Max-Age of 10 years. [Chrome’s developer blog](https://developer.chrome.com/blog/cookie-max-age-expires) says it caps cookie lifetime at 400 days, so the browser shortens the date and the cookie expires on Chrome’s schedule, not the site’s request.

The browser has no control over what the server decides. These causes are separate from any cookie date:

- Idle timeout: the server ends a session after a period without activity.

- Absolute session limit: the server forces a new login after a fixed time, however active you are.

- Password change: the server can invalidate existing sessions.

- Revocation: signing out of a device or of all devices kills that session.

In each case the cookie file still looks fine in your browser, but the server no longer accepts it.

## Which browser settings quietly shorten your logins?

Clear-on-exit, private windows, third-party cookie blocking, Safari’s tracking prevention timers and forgotten cleanups cut logins short most often. Each one protects privacy at a cost to your sessions.

1. **Clear cookies on exit.** Chrome’s cookie settings have “Clear cookies and site data when you close all windows”, and Firefox’s Privacy & Security page has “Delete cookies and site data when Firefox is closed”. Either toggle makes every login last only until you quit the browser, whatever date the cookie carries.

2. **Private windows and ephemeral profiles.** The browser discards their cookies when the window or profile closes, by design. They suit a one-off check on an account you don’t use, and they are the wrong place for any account you want to stay signed in to.

3. **Third-party cookie blocking.** In Chrome it sits under Settings, Privacy and security, Third-party cookies. A site’s own login cookie is a first-party cookie, so blocking leaves it alone. Embedded login frames and cross-site widgets break instead, and they may ask you to sign in again inside the embed.

4. **Safari Intelligent Tracking Prevention (ITP).** [WebKit’s post on full third-party cookie blocking](https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/) describes a cap on script-writable storage, which ITP deletes after “seven days of Safari use without user interaction on the site”. A login that depends on script-written cookies or local storage is the one at risk. Using the site at least once a week keeps you inside that window.

5. **A cleanup you forgot about.** Chrome’s “Delete browsing data” dialog removes logins when “Cookies and other site data” is ticked, for whatever time range you picked. Untick that box when you only want to clear history or cache.

### What to check first when a login keeps dropping

- Is the window private, or is the profile ephemeral?

- Is clear-on-exit switched on in the browser?

- Did your last “Delete browsing data” run include cookies?

Then check the less obvious causes:

- Does the login only fail inside an embed or a “sign in with” frame? If so, suspect third-party blocking.

- On Safari, did more than seven days pass without you using that site?

- Does an extension or a cleaner app wipe cookies on a schedule?

If every answer is no, the site’s server most likely ended the session, and only a fresh login fixes that.

## How to keep browser cookies fresh when you clean up

Here is how to keep browser cookies fresh when you clean up: delete only the sites that need it, protect the logins you rely on, and save a backup first. A full wipe signs you out everywhere at once, and you only learn which sessions you needed as each one fails.

1. **List the accounts you can’t afford to lose.** Write down the email, ad dashboards, store admin panels, exchanges and any login that is slow to recover because of two-factor prompts. Five minutes is enough.

2. **Set an allowlist or delete per site.** Each browser has its own place for this:

- In Chrome, open Settings, then Privacy and security, then Third-party cookies, then “See all site data and permissions”, search the domain and delete that entry only, or add the site to the list that can always keep cookies.

- Firefox offers Manage Exceptions and Manage Data under Cookies and Site Data in Privacy & Security.

- Safari offers Manage Website Data under Privacy.

Avoid the “Delete browsing data” dialog with “Cookies and other site data” ticked for routine cleanup, because it clears every site in the chosen time range.

1. **Export your cookies before you delete anything.** Browsers have no export button, so use a cookie manager extension or a profile manager that supports export. Save the file somewhere encrypted and delete it when you’re done, because anyone holding it can sign in as you.

2. **Restore from the export if a cleanup goes wrong.** Import the file and reload the site. A restored cookie only works if the server hasn’t expired the session yet. After a long idle period or a password change, the site will ask you to log in again, and that is the correct outcome.

3. **Test one site before the rest.** Delete the entries for a single low-risk site, reload it, and confirm that your protected logins still open. If the allowlisted accounts stay signed in, repeat the cleanup for the remaining sites. If one asks for a password, go back to step 4 before you continue.

A successful cleanup removes stale trackers, and every account on your step 1 list opens without a login prompt.

## How to keep browser cookies fresh across several accounts and regions

Here is how to keep browser cookies fresh across several accounts and regions: give each identity (a client, a brand or a region) its own isolated cookie jar, then log in from the same IP, timezone and fingerprint every time.

A single shared jar breaks down because one login can push out another on the same site.

A container changes where cookies are stored, but your IP address stays the same. A fully isolated profile separates more.

In Donut Browser, the [project’s README on GitHub](https://github.com/zhom/donutbrowser) says each profile is “fully isolated”, with its own fingerprint, cookies, local storage, cache and extensions. The [explainer on anti-detect browsers](https://donutbrowser.com/what-is-an-anti-detect-browser) covers how that works.

1. **Create one profile per identity.** Name it by identity, such as `acme-us-instagram`. Never log two identities into one profile, because the second login can replace the first session on that site and tie the accounts together.

2. **Assign one proxy to each profile**, located in that identity’s region. The [proxy guide for anti-detect browsers](https://donutbrowser.com/proxies-for-anti-detect-browsers) recommends one dedicated proxy per profile. Donut Browser does not sell proxies, so you bring your own.

3. **Match timezone and language to the proxy.** The same guide notes the browser reports a timezone from the profile, not the proxy, so a New York IP with an Asia/Ho\_Chi\_Minh timezone looks inconsistent. Check what each profile reveals against [browser fingerprinting signals](https://donutbrowser.com/browser-fingerprinting).

4. **Log in once, then reuse that profile.** A saved session is more likely to survive when the IP, timezone and fingerprint match the ones it was created with. That lowers a risk and guarantees nothing, since the site can still expire the session.

5. **Open each profile weekly and confirm you’re still logged in.** A healthy profile shows no password prompt and the expected city on an IP check.

## Is it safe to keep, export and move cookies between devices?

Keeping and moving cookies carries a security cost, because the site treats whoever presents a session cookie as the logged-in user.

[Lifehacker warns](https://lifehacker.com/tech/best-privacy-hacks-browser-cookies) that cookies can “even hijack your active browser session to log into your accounts without a password”, so a cookie file deserves the same care as a password list. The site checks the cookie, so a copy skips the login step that created it.

Two cookie attributes limit the damage. `HttpOnly` hides a cookie from page scripts, and `Secure` sends it only over HTTPS. Neither helps once the cookie sits in a file you exported.

The risk comes from three places:

- Exported cookie files. Most exports are plain text, and anyone who opens the file can paste the cookies into another browser.

- Cookie-manager extensions. Many ask to read and change data on every site you visit. Install only ones you trust, and remove them when the job is done.

- Unencrypted sync. Check whether the provider can read your cookies or only you can.

If you export cookies for 12 client accounts to one file on your desktop, that file is 12 logins in one place. Move it once, import it, then delete it. If you must keep it, store it in an encrypted archive or an encrypted drive.

For regular moves between profiles and machines, prefer a sync that is end-to-end encrypted with a password only you know. Self-hosting the sync server keeps the data on storage you control.

If you lose track of a file, a laptop or an extension, end the session from the account side:

1. Open the site’s security or account settings.

2. Find the list of signed-in devices or active sessions.

3. Sign out of every entry you don’t recognize, or all of them.

4. Change the password, since many sites end other sessions after a password change.

Google Account Help and other platform help centers describe this device list, usually under security settings. Run these steps for each site where you exported a login.

## Can cookies stay fresh while your computer is off?

Cookies can stay fresh while your computer is off only if another machine keeps using the profile for you.

Solo includes 40 Cookie Bot hours, and Pro includes 200 remote execution and Cookie Bot hours.

Warming a profile this way keeps a live session in use, and it has limits. Warming cannot:

- beat server-side expiry, where the site ends a session on its own clock;

- get past an absolute session limit, a cap counted from the moment you logged in, however active the profile is;

- survive a password reset;

- bring back a session the site has revoked.

A fresh login is the correct fix after a password change, a security alert, a revoked device or a suspicious-login notice. Don’t try to restore a dead session by importing old cookies. The server has already rejected them, and repeated failed attempts look worse than one clean sign-in.

Donut Browser doesn’t guarantee that accounts avoid bans, and warming doesn’t replace normal use. Keep logging in and working in each profile as you would anyway.

If you run several client or regional accounts, [compare Solo and Pro on the pricing page](https://donutbrowser.com/pricing) and check which allowance matches your overnight profiles.

## How do you keep login state in Playwright, Puppeteer and Selenium?

You keep login state in Playwright, Puppeteer and Selenium by saving the cookies after one login and loading them into the next run’s fresh browser context. A new context starts empty, so without this step every run logs in again.

1. **Save the state in Playwright.** The [Playwright authentication docs](https://playwright.dev/docs/auth) save the state after login with `storageState` and reuse it from a file under `playwright/.auth/`. Run the login once, then load the file in your config:

```
const authFile = 'playwright/.auth/user.json';

// after logging in on the page
await page.context().storageState({ path: authFile });

// playwright.config.ts
use: { storageState: 'playwright/.auth/user.json' }
```

1. **Read and set cookies in Puppeteer.** [Puppeteer’s BrowserContext reference](https://pptr.dev/api/puppeteer.browsercontext.cookies) documents `cookies()` and `setCookie()` on the browser context, described as “Gets all cookies in the browser context.” Dump the cookies to JSON after login and set them before the first navigation. Check the current reference for exact signatures, because the older page-level cookie methods have changed.

2. **Add cookies in Selenium.** The [Selenium cookie docs](https://www.selenium.dev/documentation/webdriver/interactions/cookies/) cover the WebDriver commands that “add a cookie to the current browsing context.” Open the site’s domain first, then add each saved cookie, or the add command has no matching domain to attach to.

3. **Attach to a persistent profile instead.** The profile keeps its own cookies between runs. The [automation use case](https://donutbrowser.com/use-cases/automation) describes the wider setup.

4. **Protect the file and rebuild it when it dies.** Playwright warns that saved state files can impersonate your test account and says, “We strongly discourage checking them into private or public repositories.” Add the folder to `.gitignore`. When a run lands on the login page, the site has expired the session, so delete the file and log in again.

A working setup opens a logged-in page on the second run with no login step.

## Frequently asked questions

### How do I stop a website from logging me out?

**Don’t clear cookies on exit, and use the site often enough that the server’s idle timer never runs out.** Stay in the same browser profile and open the site regularly so the timer resets. Once the server has expired or revoked the session, you must log in again.

### Do cookies expire if I do not visit a site?

**A cookie can expire without a visit, either on its own date or when the server ends an idle session.** The browser deletes a persistent cookie at its Expires or Max-Age date. The server can also drop your session after a period of inactivity, even though the cookie is still on your computer.

### Is it safe to export my cookies?

**It’s safe only if you treat the file like a password.** Anyone who opens an export can load your sessions into another browser. Store exports encrypted, never share them, and delete old copies.

### Can I keep cookies when I clear my browser data?

**You can, by clearing data for individual sites instead of everything.** Remove the sites that misbehave and leave the logins you rely on. Save a cookie export first, so you can restore a session you deleted by mistake.

## How to keep browser cookies fresh: your next steps

Today, turn off clear-on-exit for the sites you need, stop logging in to long-lived accounts through Incognito windows, and export a cookie backup before any cleanup.

This week, give each client, brand or region its own isolated profile, and revoke old sessions on your key accounts.

This month, add scheduled warming or saved login state to your automation, then review which sessions expire and why. When a server ends a session, log in again and start the backup from the new session.

### Where Donut Browser fits

Every step on how to keep browser cookies fresh works in any browser. If you want per-identity isolation built in, download [Donut Browser](https://donutbrowser.com/) from the homepage. It’s open source with zero telemetry, and [the free plan needs no account](https://donutbrowser.com/alternatives/adspower/). Move one identity into its own profile and see whether its login holds through next week.

## Sources

[Cookie Max-Age and Expires capped to 400 days (Chrome for…](https://developer.chrome.com/blog/cookie-max-age-expires) · [10 Privacy Hacks for Managing Browser Cookies Everyone…](https://lifehacker.com/tech/best-privacy-hacks-browser-cookies) · [Authentication | Playwright](https://playwright.dev/docs/auth) · [Using HTTP cookies - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies) · [RFC 6265: HTTP State Management Mechanism](https://datatracker.ietf.org/doc/html/rfc6265) · [Proxies for Anti-Detect Browsers](https://donutbrowser.com/proxies-for-anti-detect-browsers/) · [Pricing: Free Forever, Solo, Pro and Team — Donut Browser](https://donutbrowser.com/pricing/) · [Private anti-detect browser — Donut Browser](https://donutbrowser.com). Every other source is linked where the article cites it.

## Google で当サイトをもっと見る

ワンクリックで Donut Browser を Google アカウントの優先ソースに設定すると、トップニュース、AI モード、AI による概要で当サイトの記事が表示されやすくなります。

Google で優先ソースに設定

## On this page

- Why do browser cookies go stale before you expect?

- Which browser settings quietly shorten your logins?

- What to check first when a login keeps dropping

- How to keep browser cookies fresh when you clean up

- How to keep browser cookies fresh across several accounts and regions

- Is it safe to keep, export and move cookies between devices?

- Can cookies stay fresh while your computer is off?

- How do you keep login state in Playwright, Puppeteer and Selenium?

- Frequently asked questions

- How do I stop a website from logging me out?

- Do cookies expire if I do not visit a site?

- Is it safe to export my cookies?

- Can I keep cookies when I clear my browser data?

- How to keep browser cookies fresh: your next steps

- Where Donut Browser fits

- Sources
