Documentation 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.
RammerheadSession extends testcafe-hammerhead’s Session class with cookie and localStorage persistence, URL-shuffling dictionaries, and serialization support. Each user that navigates through the proxy gets exactly one session, identified by a random ID. Sessions are normally created and retrieved through a session store — you rarely instantiate RammerheadSession directly.
The recommended way to create sessions is through a session store’s
add(id) method after calling store.attachToProxy(proxy). Direct construction is only needed when deserializing a previously serialized session or in advanced testing scenarios.Constructor
Unique session identifier. Defaults to a randomly generated alphanumeric string. Pass an explicit value when reconstructing a session from storage.
When
true, the constructor skips the call to connectHammerheadToData(). Use this when you need to set session.data from a deserialized source before connecting hammerhead’s internal state to it. DeserializeSession uses this flag.When
true, session.shuffleDict is set to null and URL shuffling is not applied for this session. Shuffling is enabled by default.Array of script URLs to inject into every proxied page before
rammerhead.js. Useful for injecting custom initialization scripts.Properties
Plain object that acts as the backing store for all session state (cookies, localStorage,
createdAt, lastUsed, shuffleDict, and injectable). The connectHammerheadToData method wires hammerhead’s internal properties to read and write through this object, so data always reflects the current session state and is safe to serialize.Unix timestamp (milliseconds) when the session was created. Set once during construction and stored in
data.createdAt.Unix timestamp (milliseconds) of the last time the session was accessed. Updated by calling
updateLastUsed(). Session stores use this value to evict stale sessions.Upstream proxy configuration used by hammerhead when making outbound requests. When set, all requests from this session are forwarded through the specified upstream proxy.
When non-null, this value takes precedence over
externalProxySettings for outbound requests. Useful for server-side proxy enforcement that cannot be overridden by client-supplied settings.The URL-shuffling character map dictionary for this session. Generated once by
StrShuffler.generateDictionary() during construction. null when shuffling is disabled (disableShuffling: true). Clients fetch this dictionary from /api/shuffleDict?id=<sessionId> to decode proxied URLs.Methods
connectHammerheadToData
createdAt, lastUsed, injectable, externalProxySettings, shuffleDict, and optionally cookies) to read from and write to session.data. Call this after manually setting session.data when deserializing.
When
true, the cookie jar is not connected to data. Pass true when using serializeSession/DeserializeSession because those methods handle cookie serialization separately.updateLastUsed
session.lastUsed to the current time (Date.now()). Session stores call this automatically on get(). Call it manually after any operation that counts as session activity.
serializeSession
data and the serialized cookie jar. Use this to save a session to disk or transfer it between processes.
A JSON string with shape
{ data: object, serializedCookieJar: object }.DeserializeSession (static)
RammerheadSession from a JSON string previously produced by serializeSession().
Session ID to assign to the restored session.
JSON string as returned by
serializeSession().A fully initialized session with
data and cookies restored.setExternalProxySettings
null clears the upstream proxy.
An upstream proxy configuration object or
null to remove it. Uses the same shape as externalProxySettings.Example: creating and deserializing sessions
- Via store (recommended)
- Direct construction