TabSailTabSail

State reuse

Choose between a live browser and saved browser state.

NeedApproach
Several steps with the same loginUse the same live session and context
Another tab in the same workflowCreate a page in the existing context
Reconnect after a transport interruptionRequest a fresh grant for the same ready session
Reuse login in a new sessionProfiles
Recover lost browser memoryStart a new workflow; the old memory is gone

With an initialized client, Playwright's chromium import, and a stored session ID:

const session = await client.sessions.get(sessionId);
if (session.status !== "ready" || session.controller !== "automation") {
  throw new Error("Automation cannot reconnect");
}
const grant = await client.sessions.connections.create(session.id, { type: "cdp" });
const browser = await chromium.connectOverCDP(grant.url);
try {
  const context = browser.contexts()[0];
  const page = context.pages()[0] ?? await context.newPage();
  console.log(await page.title());
} finally {
  await browser.close();
}

This reconnects and disconnects; your application's owner still closes the session. Use a separate session for an independent website account.

Use a separate Profile for each authorized website account. Profiles belong to the project; your backend maps them to users.