The set_cookie parameter allows you to set cookies before the rendering process begins.

Overview

When rendering webpages that require authentication or personalization, you may need to set specific cookies. The set_cookie parameter lets you configure cookies that will be sent with requests during the rendering process.

Parameter details

Configures cookies that will be sent with requests during the rendering process

Usage

{
  "parts": "https://example.com/members-only",
  "set_cookie": {
    "name": "session_id",
    "value": "abc123xyz",
    "domain": "example.com"
  }
}

Behavior

The specified cookie is set before any requests are made during the rendering process. This allows you to:

  • Access authenticated content
  • View personalized pages
  • Bypass login screens
  • Render content that requires specific cookie values

Important notes

  • The domain value must match the domain of the URL being rendered
  • Only one cookie can be set per request
  • Cookies are only valid for the current rendering session

Use cases

This parameter is particularly useful for:

  1. Authenticated content: Render pages that require user login by providing session cookies.

  2. Personalized views: Capture user-specific views by setting identity or preference cookies.

  3. Testing: Validate how pages appear with different cookie values.

Examples

Accessing a members-only page

{
  "parts": "https://example.com/members-only",
  "set_cookie": {
    "name": "session_id",
    "value": "abc123xyz",
    "domain": "example.com"
  }
}

Setting a user preference

{
  "parts": "https://example.com/dashboard",
  "set_cookie": {
    "name": "theme",
    "value": "dark",
    "domain": "example.com"
  }
}
{
  "parts": "https://example.com",
  "set_cookie": {
    "name": "cookie_consent",
    "value": "accepted",
    "domain": "example.com"
  }
}