# Custom Cookies

If you would like to send custom cookies to the target website, simply add them as parameters to the request or as the “Wsa-Cookie” header (see Custom-Headers section).

In the right-side box, you will find an example request used to scrape the URL <https://httpbin.org/cookies>, which will mirror the cookies sent.

### **Custom Cookies examples**

> **`GET https://scrape.shifter.io/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies`**

**⇡ Input**

{% tabs %}
{% tab title="cURL" %}

```url
curl --request GET --url "https://scrape.shifter.io/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies" --header "Wsa-Accept: application/json" --header "Wsa-Cookie: name1=value1; name2=value2"
```

{% endtab %}

{% tab title="NodeJS" %}

```javascript
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "scrape.shifter.io",
  "port": null,
  "path": "/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies",
  "headers": {
    "Wsa-Accept": "application/json",
    "Wsa-Cookie": "name1=value1; name2=value2"
  }
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
```

{% endtab %}

{% tab title="Python" %}

```python
import http.client

conn = http.client.HTTPSConnection("scrape.shifter.io")

headers = {
    'Wsa-Accept': "application/json",
    'Wsa-Cookie': "name1=value1; name2=value2"
    }

conn.request("GET", "/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://scrape.shifter.io/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Wsa-Accept: application/json",
    "Wsa-Cookie: name1=value1; name2=value2"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

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

func main() {

	url := "https://scrape.shifter.io/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Wsa-Accept", "application/json")
	req.Header.Add("Wsa-Cookie", "name1=value1; name2=value2")

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

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="Java" %}

```java
HttpResponse<String> response = Unirest.get("https://scrape.shifter.io/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies")
  .header("Wsa-Accept", "application/json")
  .header("Wsa-Cookie", "name1=value1; name2=value2")
  .asString();
```

{% endtab %}

{% tab title=".NET" %}

```
var client = new RestClient("https://scrape.shifter.io/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies");
var request = new RestRequest(Method.GET);
request.AddHeader("Wsa-Accept", "application/json");
request.AddHeader("Wsa-Cookie", "name1=value1; name2=value2");
IRestResponse response = client.Execute(request);
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://scrape.shifter.io/v1?api_key=api_key&url=http%3A%2F%2Fhttpbin.org%2Fcookies")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["Wsa-Accept"] = 'application/json'
request["Wsa-Cookie"] = 'name1=value1; name2=value2'

response = http.request(request)
puts response.read_body
```

{% endtab %}
{% endtabs %}

**⇣ Output**

```
{
    "cookies": {
        "name1": "value1",
        "name2": "value2"
    }
}
```
