> ## Documentation Index
> Fetch the complete documentation index at: https://docs.surfsky.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Cookies

> Export or import a profile's cookies and troubleshoot logins that do not survive a restart.

Persistent profiles save cookies by default. You only need the cookie endpoints when transferring cookies between a profile and another system. For ordinary login reuse, start the same [persistent profile](/sessions#persistent-profiles).

Use these endpoints on a stopped profile. To inspect or change cookies in a running browser, use your framework's cookie API in the existing context.

## Export

```bash theme={null}
curl --fail-with-body \
  "$SURFSKY_API_BASE_URL/profiles/PROFILE_UUID/cookies?export_format=json" \
  -H "X-Cloud-Api-Token: $SURFSKY_API_TOKEN"
```

The response places the cookies in `data.cookies`. JSON export returns an array; `export_format=netscape` returns cookie-file text.

Example JSON export, with a redacted value:

```json theme={null}
{
  "success": true,
  "msg": "Cookies were exported",
  "data": {
    "cookies": [
      {
        "domain": ".example.com",
        "name": "session",
        "value": "REDACTED",
        "path": "/",
        "secure": true,
        "httpOnly": true
      }
    ]
  }
}
```

`cookies_not_found` means there are no stored cookies to export. `cookies_disabled` means cookie storage is disabled for the profile.

## Import

For the import endpoint, send the serialized cookies in the `cookies` field:

```bash theme={null}
curl --fail-with-body \
  "$SURFSKY_API_BASE_URL/profiles/PROFILE_UUID/cookies" \
  -H "X-Cloud-Api-Token: $SURFSKY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"cookies": "[{\"domain\":\".example.com\",\"name\":\"session\",\"value\":\"YOUR_COOKIE_VALUE\",\"path\":\"/\",\"secure\":true}]"}'
```

The string can contain a serialized JSON cookie array or Netscape cookie text. Importing an expired cookie does not renew the website's session.

At profile creation, `cookies` also accepts an array:

```json theme={null}
{
  "title": "my profile",
  "fingerprint": { "os": "win" },
  "cookies": [
    {
      "domain": ".example.com",
      "name": "session",
      "value": "YOUR_COOKIE_VALUE",
      "path": "/"
    }
  ]
}
```

Cookie values can grant access to signed-in accounts. Store exports securely and redact them from logs and support requests.

## Sessions that will not stay logged in

Check the state restored by the next run:

| Check                                            | What to do                                                                                                     |
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| The profile is one-time                          | Create a persistent profile and reuse its saved UUID.                                                          |
| The profile was still running                    | A start request on a running profile returns that session and ignores new settings. Stop it, then start again. |
| The site stores authentication in local storage  | Enable `storage_options.localstorage` before signing in again.                                                 |
| The previous session ended in a crash or failure | State after the last saved stop is lost. Sign in again and wait for the stop response before restarting.       |
| The cookie has expired or been revoked           | Authenticate again; restoring the cookie cannot extend its validity.                                           |
| The site asks to verify a new device or location | Check for changes to the fingerprint or proxy IP.                                                              |

Service workers can also hold application state. Enable `storage_options.serviceworkers` if the site needs it. The [storage options table](/sessions#what-gets-saved) lists all defaults.
