WebScrapingAPI Docs

Custom Cookies

Send custom cookies to the target website through Browser API.

Custom cookies are useful when the target website expects visitor preferences, locale state, or another non-authentication cookie value.

Browser API accepts custom cookies through the WSA-Cookie request header. The API strips the WSA- prefix, sends the remaining Cookie header to the target page, and applies the parsed cookies to the browser context.

Browser API does not allow custom cookies for authentication bypass. Keep session and account cookies out of client-side code.

Only the following cookies can be overwritten:

  • locale
  • currency
  • location
  • CUSTOMER_CONTEXT

Additional cookies may be added per domain by contacting customer support.

Integration Examples

curl --request GET \
  --url "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fcookies" \
  --header "wsa-cookie: CUSTOMER_CONTEXT=12345; currency=USD"
const response = await fetch("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fcookies", {
  method: "GET",
  headers: {
    "wsa-cookie": "CUSTOMER_CONTEXT=12345; currency=USD"
  }
});

const data = await response.text();
console.log(data);
import requests

params = {
    "api_key": "<YOUR_API_KEY>",
    "url": "https://httpbin.org/cookies",
}

headers = {
    "wsa-cookie": "CUSTOMER_CONTEXT=12345; currency=USD",
}

response = requests.get("https://api.webscrapingapi.com/v1", params=params, headers=headers)
print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fcookies",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "wsa-cookie: CUSTOMER_CONTEXT=12345; currency=USD"
  ],
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fcookies", nil)
	req.Header.Add("wsa-cookie", "CUSTOMER_CONTEXT=12345; currency=USD")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	body, _ := io.ReadAll(res.Body)
	fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.get("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fcookies")
  .header("wsa-cookie", "CUSTOMER_CONTEXT=12345; currency=USD")
  .asString();
var client = new RestClient("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fcookies");
var request = new RestRequest(Method.GET);
request.AddHeader("wsa-cookie", "CUSTOMER_CONTEXT=12345; currency=USD");
IRestResponse response = client.Execute(request);
require 'uri'
require 'net/http'

url = URI("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=http%3A%2F%2Fhttpbin.org%2Fcookies")
request = Net::HTTP::Get.new(url)
request["wsa-cookie"] = "CUSTOMER_CONTEXT=12345; currency=USD"

response = Net::HTTP.start(url.hostname, url.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body

On this page