Table of Content
The Cookie HTTP request header contains stored HTTP cookies previously sent by the server with the Set-Cookie header. The Cookie header is optional and can be omitted if the client doesn't have any cookies. The purpose of the cookie is to remember stateful information (such as items added in the shopping cart on an online store) or to record the user's browsing activity (including clicking particular buttons, logging in, or recording which pages were visited in the past).
Whereby <cookie-list> is a list of name-value pairs in the form of NAME=VALUE; separated by semicolons.
The Cookie header doesn't have specific directives. Instead it has name-value pairs separated by semicolons.
Cookie: name=value; name2=value2; name3=value3
This example presents setting multiple cookies where name, name2 and name3 are cookie names while value, value2 and value3 are corresponding values.
All modern browsers support the Cookie header.
How to modify Cookie header
ModHeader is a Chrome extension that can be added to the browser for modifying both request and response headers. You can use it to modify the Cookie header to test or debug your application.
To modify the Cookie header using ModHeader, follow these steps:
- Add ModHeader to your Chrome browser.
- Click the ModHeader icon beside the URL bar to open it.
- Click on '+ Add' to create a new profile.
- In the 'Request headers' section, enter 'Cookie' in the 'Name' field, and then your desired cookie information in the 'Value' field, something like 'name=value'.
- Now, when you make requests, the Cookie header will include your modifications.
This comes handy when you need to set up mock tests or when you need to debug by emulating certain conditions, like different session states.