Skip to main content
Camofox provides complete session isolation for multi-user browser automation. Each user gets their own browser context with isolated cookies, localStorage, and browsing state.

Architecture

Sessions follow a three-level hierarchy:

Visual diagram

userId vs sessionKey

userId (Context level)

Purpose: Isolates users from each other. Each userId gets a dedicated browser context. Isolation:
  • Separate cookies
  • Separate localStorage/sessionStorage
  • Separate browsing history
  • Separate cache
Example use cases:
  • Different end users in a multi-tenant system
  • Different accounts (personal vs work)
  • A/B testing with separate profiles
From server.js:425-452:

sessionKey (Tab group level)

Purpose: Organizes tabs within a user’s context by task/conversation/workflow. Isolation:
  • Shares cookies with other tab groups in the same userId
  • Logical grouping only (not security boundary)
  • Allows bulk tab operations (close all tabs in a task)
Legacy alias: Previously called listItemId. Both names are accepted for backward compatibility. From server.js:834-836:
Example use cases:
  • Grouping tabs by conversation thread
  • Organizing research tasks
  • Batch closing related tabs
Key distinction: userId isolates cookies, sessionKey organizes tabs. Use userId for security, sessionKey for organization.

Per-user cookies

Each userId gets its own cookie jar:
Alice and Bob maintain separate sessions on site-a.com.
Cookie import is disabled by default for security. Set CAMOFOX_API_KEY to enable.
From server.js:102-108:
When enabled, import cookies to pre-authenticate a user:
Security checks:
  • Requires Bearer token matching CAMOFOX_API_KEY
  • Max 500 cookies per request
  • Only allows: name, value, domain, path, expires, httpOnly, secure, sameSite
  • Strips unknown fields
From server.js:150-157:

Session timeout

From server.js:176:

How timeout works

  1. lastAccess tracking: Every API call updates session.lastAccess = Date.now()
  2. Cleanup interval: Every 60 seconds, server checks for stale sessions
  3. Auto-close: Sessions idle for 30+ minutes are closed and removed
From server.js:1470-1483:
For long-running tasks, make periodic API calls (like snapshot or health check) to keep the session alive.

Resource limits

From server.js:176-180:

Limits enforcement

Max sessions:
Max tabs per session:
  • When limit reached, Camofox recycles the oldest tab instead of rejecting
  • Oldest = tab with lowest toolCalls counter
From server.js:890-911:
Tab recycling ensures automation never fails due to tab limits - the oldest idle tab is reused transparently.

Session cleanup endpoints

Close single tab

From server.js:1409-1428:
  • Closes page
  • Removes from tab group
  • Cleans up tab lock
  • If group becomes empty, deletes group

Close tab group

Closes all tabs in a sessionKey:

Close entire user session

From server.js:1452-1467:
  • Closes browser context (all tabs + cookies)
  • Removes session from memory
  • If last session, triggers browser idle shutdown timer
Closing a session permanently deletes all cookies and browsing data for that userId. There is no undo.

Browser lifecycle

Lazy launch

Browser launches only when first tab is created:

Idle shutdown

From server.js:301-317:
Behavior:
  • When last session closes, start 5-minute countdown
  • If new session created, cancel countdown
  • After 5 minutes of zero sessions, close browser to free resources

Health recovery

From server.js:344-367:
Browser auto-restarts if:
  • 3+ consecutive navigation failures
  • Browser becomes disconnected
  • Critical internal error

Concurrency control

From server.js:232-264:
Purpose: Prevents a single user from monopolizing browser resources with 10+ parallel operations. Behavior:
  • Max 3 operations per userId can run simultaneously
  • Excess operations queue for up to 30 seconds
  • After 30s, returns error: “User concurrency limit reached, try again”
For bulk automation, process tasks sequentially or across multiple userIds to avoid queueing delays.

Example workflows

Multi-user isolation

Task-based tab groups

Session cleanup