Documentation Index
Fetch the complete documentation index at: https://mintlify.com/steerlabs/opensteer/llms.txt
Use this file to discover all available pages before exploring further.
Overview
OpenSteer provides methods to export and import browser cookies. These methods allow you to save cookies to a file and restore them later.
Cookie export and import methods are local-only features. They are not supported in cloud mode because they depend on local filesystem paths.
Methods
getCookies
Get cookies from the browser context, optionally filtered by URL.
await opensteer.getCookies(url?: string): Promise<Cookie[]>
Optional URL to filter cookies. If provided, only cookies for this URL will be returned
Array of cookie objects from Playwright
Example
import { Opensteer } from 'opensteer'
const opensteer = new Opensteer()
await opensteer.launch()
await opensteer.goto('https://example.com')
// Get all cookies
const allCookies = await opensteer.getCookies()
console.log(`Total cookies: ${allCookies.length}`)
// Get cookies for specific URL
const siteCookies = await opensteer.getCookies('https://example.com')
await opensteer.close()
setCookie
Set a single cookie in the browser context.
await opensteer.setCookie(cookie: CookieParam): Promise<void>
Cookie object to set (see CookieParam type below)
Example
import { Opensteer } from 'opensteer'
const opensteer = new Opensteer()
await opensteer.launch()
// Set a cookie
await opensteer.setCookie({
name: 'session_id',
value: 'abc123',
domain: 'example.com',
path: '/',
secure: true,
httpOnly: true
})
await opensteer.goto('https://example.com')
await opensteer.close()
clearCookies
Clear all cookies in the browser context.
await opensteer.clearCookies(): Promise<void>
Example
import { Opensteer } from 'opensteer'
const opensteer = new Opensteer()
await opensteer.launch()
await opensteer.goto('https://example.com')
// Clear all cookies
await opensteer.clearCookies()
// Verify cookies are cleared
const cookies = await opensteer.getCookies()
console.log(`Cookies remaining: ${cookies.length}`) // 0
await opensteer.close()
exportCookies
Exports cookies from the browser context to a JSON file.
await opensteer.exportCookies(filePath: string, url?: string): Promise<void>
Path to the file where cookies will be saved
Optional URL to filter cookies. If provided, only cookies for this URL will be exported
Example
import { Opensteer } from 'opensteer'
const opensteer = new Opensteer()
await opensteer.launch()
// Navigate to a site
await opensteer.goto('https://example.com')
// Export all cookies
await opensteer.exportCookies('./cookies.json')
// Export cookies for specific URL
await opensteer.exportCookies('./example-cookies.json', 'https://example.com')
await opensteer.close()
importCookies
Imports cookies from a JSON file into the browser context.
await opensteer.importCookies(filePath: string): Promise<void>
Path to the JSON file containing cookies to import
Example
import { Opensteer } from 'opensteer'
const opensteer = new Opensteer()
await opensteer.launch()
// Import previously saved cookies
await opensteer.importCookies('./cookies.json')
// Navigate to site with restored cookies
await opensteer.goto('https://example.com')
await opensteer.close()
CookieParam Type
Cookies are represented using the CookieParam type:
interface CookieParam {
name: string
value: string
url?: string
domain?: string
path?: string
expires?: number
httpOnly?: boolean
secure?: boolean
sameSite?: 'Strict' | 'Lax' | 'None'
}
URL associated with the cookie
Expiration timestamp (Unix time in seconds)
Whether the cookie is HTTP-only
Whether the cookie requires a secure connection
sameSite
'Strict' | 'Lax' | 'None'
SameSite policy for the cookie