Guides

Persist a login

Log in once, save the session storage to a named snapshot, and load it later to skip the login entirely.

Logging in on every run is slow and fragile. Instead, authenticate once, save the resulting session storage to a named snapshot, and load that snapshot in later runs — you land already logged in. bl storage save snapshots cookies, localStorage, and sessionStorage; bl storage load restores them.

Log in once and save the state

Authenticate

Drive the login form like any other — fill the fields and submit:

bl open https://app.example.com/login
bl fill "input[name=email]" "user@example.com"
bl fill "input[name=password]" "secret"
bl click "button[type=submit]"
bl wait url "/dashboard"

The bl wait url is important: it confirms the login actually completed before you snapshot the state.

Save the snapshot

bl storage save auth

This snapshots the browser's cookies, localStorage, and sessionStorage under the name auth, stored in browserlane's local cache. Use bl storage list to see saved snapshots and bl storage show auth for redacted metadata (counts only — never raw values).

Restore it later and skip the login

In a future run, load the snapshot and go straight to an authenticated page — no login form needed:

bl storage load auth
bl open https://app.example.com/dashboard

That's the whole payoff: every subsequent run starts from a logged-in browser.

Saved snapshots hold secrets

A saved snapshot contains live session cookies and tokens — anyone who can read it can act as the logged-in user. bl storage show never prints raw values, and bl storage export <name> -o <path> is the only way to write them out. Keep exported files secure, out of version control, and rotate them if they leak.

When the saved session expires

Sessions don't last forever — cookies expire and tokens get revoked. When a restored session no longer works (you get bounced back to the login page), just re-run the login-and-save step to refresh the auth snapshot. A simple guard is to load it, hit a protected page, and check where you ended up:

bl storage load auth
bl open https://app.example.com/dashboard
bl url    # if this is the login page, the session expired — re-authenticate

Cookies only

If you only need to set or read individual cookies — rather than the full storage state — use bl cookies:

bl cookies                       # list all cookies
bl cookies "session" "abc123"    # set a single cookie
bl cookies clear                 # clear them all

For persisting a real login, prefer bl storage save: many apps keep auth in localStorage or sessionStorage too, which bl cookies doesn't touch.

On this page