🎉 Requestly joins BrowserStack to build the future of application testing. Read more

HTTP Headers

Cookie

HTTP Header

The HTTP Cookie request header contains stored HTTP cookies associated with the server, which were previously sent by the server using the Set-Cookie header or set in JavaScript through Document.cookie.

The Cookie header is classified as a Request header and is typically sent with requests to the server.
It is considered a Forbidden request header, meaning certain restrictions apply to its use due to security considerations.

Syntax

http
Cookie: <cookie-list>
Cookie: name=value
Cookie: name=value; name2=value2; name3=value3

Directives

<cookie-list>

A list of name-value pairs in the form of <cookie-name>=<cookie-value>.Pairs in the list are separated by a semicolon and a space.

Example

http
Cookie: PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1

How to Modify Header using Requestly

Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Cookie header. This is especially useful for testing how your application handles different cookie values or managing authentication during development or debugging. Steps to Modify the Cookie Header:

  1. Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
  2. Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
  3. Add a new header modification:
    • Under “Action”, select “Add” or “Override”.
    • In the “Header Name” field, enter Cookie.
    • In the “Header Value” field, enter the cookie string you want to use (e.g., sessionId=abc123; theme=dark).
  4. Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
  5. Save the rule.

Once set up, Requestly will inject the modified Cookie header into all matching requests, allowing you to test how your app behaves with different cookie values or simulate user sessions without logging in repeatedly.