Every user of a Rammerhead proxy interacts through a session. A session stores cookies, localStorage, the URL-shuffling dictionary, and optional upstream proxy settings. Sessions can be managed through the built-in HTTP endpoints exposed byDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/binary-person/rammerhead/llms.txt
Use this file to discover all available pages before exploring further.
setupRoutes, or programmatically through the session store object in your server code.
The session store API
BothRammerheadSessionFileCache and RammerheadSessionMemoryStore implement the same interface, defined by RammerheadSessionAbstractStore. You can also implement this interface yourself for a custom backend (Redis, a database, etc.).
| Method | Signature | Description |
|---|---|---|
keys | () => string[] | Returns all session IDs currently in the store. |
has | (id: string) => boolean | Returns true if the session exists. |
get | (id: string, updateActiveTimestamp?: boolean) => RammerheadSession | undefined | Retrieves a session. Updating the timestamp (default true) prevents the session from being pruned as stale. |
add | (id: string) => RammerheadSession | Creates a new session with the given ID. Throws if the ID already exists. |
delete | (id: string) => boolean | Deletes a session. Returns true if a deletion occurred. |
addSerializedSession | (id: string, serialized: string) => void | Imports a session from a JSON string produced by session.serializeSession(). |
attachToProxy | (proxy: RammerheadProxy) => void | Assigns the store to proxy.openSessions so the proxy can look up sessions by ID. |
close | () => void | Flushes any in-memory sessions to disk (file cache only). Call this before your process exits. |
HTTP endpoints
ThesetupRoutes function registers these endpoints on the proxy. All of them are plain GET requests for simplicity, even the ones that modify state.
Create a session
password is set in your config, the pwd parameter must match or the request is rejected with 403.
restrictIP set to the requesting IP, so subsequent proxy requests from a different IP will be blocked if restrictSessionToIP is enabled in config.
Edit a session
| Parameter | Description |
|---|---|
id | The session ID to modify. Required. |
httpProxy | Set an upstream HTTP proxy for this session (e.g., http://user:pass@host:port). Omit the parameter to clear. |
enableShuffling | 1 to enable URL shuffling (generates a new dictionary if none exists), 0 to disable. |
Delete a session
Success or not found.
Check session existence
exists or not found. Does not require a password.
Programmatic session management
Creating a session
UsesessionStore.add(id) to create a session with a specific ID, or generate one first with generateId().
Restricting a session to an IP
After creating a session, setsession.data.restrictIP to an IP address string. When restrictSessionToIP is enabled in the pipeline (setupPipeline or your own handler), proxy requests from any other IP will be rejected with 403.
Setting an upstream proxy
Assign anexternalProxySettings object to route the session’s traffic through an additional HTTP proxy. The host field must include host and port.
session.externalProxySettings = null.
Session serialization and deserialization
RammerheadSession.serializeSession() returns a JSON string containing the session’s data object and cookie jar. You can store this string anywhere and restore it later with RammerheadSession.DeserializeSession(id, serialized).
File cache configuration
RammerheadSessionFileCache accepts the following options to control how sessions are stored and cleaned up.
Memory store configuration
RammerheadSessionMemoryStore keeps all sessions in memory and is simpler to configure. It is best suited for development or single-instance deployments where persistence is not required.