How to Modify Cookies Using Requestly

Modifying cookies is useful when you're testing authentication flows, simulating different user states, or tweaking behavior without changing backend code. Requestly makes this easy by letting you intercept HTTP requests/responses and manipulate cookies on the fly.

Use Cases

  • Testing login/logout behavior

  • A/B testing variants

  • Simulating admin/user roles

  • Bypassing feature flags

Modify Cookies in Requestly

This is useful for sending a custom cookie value to the server.

Cookies are sent as a single string in the Cookie header, separated by semicolons.

1

Create a New Modify Headers Rule

Go to the HTTP Rules section, click on + New Rule , and select Modify Headers from the list of options.

2

Name and Describe Your Rule

Give your rule a clear name like Set Custom Cookie. Optionally, add a short description so you can easily identify its purpose later.

3

Define Where the Rule Should Apply

Define where the rule should be applied by specifying criteria such as URL, Host, or Path. You can choose from options like Regex, Contains, Wildcard, or Equals, or use Advance Filters for more precise conditions.

For more details on source conditions, read this guide.

4

Set Up the Header Modification

In the Modification Type, select Request Headers since we're modifying outgoing request headers.
Under the Request Headers tab, click Add Header and set the following:

  • Action: Add or Override

  • Header Name: Cookie

  • Value: username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC

This tells the browser to attach the specified cookie string in all matching requests.

5

Save and Activate the Rule

Click Save to store the rule. After saving, make sure to toggle it ON to activate it.

Use document.cookie in the DevTools Console to check current cookies, or inspect request headers in the Network tab.

Updated on