How do I send a request with Cookies? [Curl/Bash Code]

To send a request with a Cookie, you need to add the "Cookie: name=value" header to your request. To send multiple cookies in a single Cookie header, separate them with semicolons or add multiple "Cookie: name=value" request headers. In this Cookies Request Example, we send Cookies in the request header to the ReqBin echo URL. Click Send to execute Cookies Request Example online and see the results. The Curl/Bash code was automatically generated for the Request Cookies example.
How do I send a request with Cookies? [Curl/Bash Code] Send
GET /echo/get/json HTTP/1.1
Cookie: name=value; name2=value2

Updated: Viewed: 20343 times
Curl/Bash code for Request Cookies example

Curl/Bash code for Request Cookies Example

This Curl/Bash code snippet was generated automatically for the Request Cookies example.
<< Back to the Request Cookies example

What is HTTP?

HTTP (Hypertext Transfer Protocol) is an application layer data transfer protocol. HTTP is used to transfer data between HTTP clients (browsers and mobile apps) and servers. HTTP is built on a request-response architecture between a client and a server. The client send a request to the server, then the server processes that request and send a response back to the client.

HTTP Cookies

HTTP Сookies is data sent from a website and stored by a web browser on a user's computer. Cookies are placed on the device (computer, mobile phone) used to access the website. These cookies are marked with an identifier that is unique to you and your computer. Cookies manage user sessions, track users and personalize (store site settings and user preferences). Browsers usually send cookies back to the server with each subsequent request, which allows the server to determine if the request came from the same browser or not.

Cookies Syntax
Cookie: cookie-name=value

What are Cookies used for?

Websites use HTTP cookies to improve the user experience when visiting the website. Cookies allow websites to remember you and do not require you to log in every time you visit a website. Cookies can keep the items in your cart and restore them when you visit the online store the next day. Cookies are stored locally on your device. If you delete cookies in your browser or visit the website in incognito mode, the website will not remember you, and you will become a new user who came to the website like the first time.

Cookies are used to:

  • Session Management: Cookies allow websites to recognize users and remember their login information and settings.
  • Tracking: Shopping sites use cookies to track products that the user has previously viewed and display similar products.
  • Personalization: Personalized ads are the primary way we use cookies. When you visit various websites, advertising sites can track you to create a profile tailored to your interests and then display targeted ads based on your profile.

How can I see saved cookies in my browser?

To view stored cookies in your browser:

  1. Press F12 to open the developer tool;
  2. Click on the Application tab;
  3. Under the "Storage" section open Cookies node and click on your website address;
  4. Here you will see all the cookies stored in your browser for this site.

How to send a Cookie request?

An example of sending Cookies request to the ReqBin echo URL:

Send Cookies Example
GET /echo/get/json HTTP/1.1
Cookie: name=value; name2=value2

See also

Generate code snippets for Curl/Bash and other programming languages

Convert your Request Cookies request to the PHP, JavaScript/AJAX, Curl/Bash, Python, Java, C#/.NET code snippets using the Curl/Bash code generator.