PuppyIP Resource Center
Cloud Operations 5 min Published 2026-12-01

Cloudflare response cookie matching: current vs. original Set-Cookie

Cloudflare added two Rules fields for reading response cookies by name on November 27. Use http.response.set_cookies to inspect headers after changes from earlier phases. Use raw.http.response.set_cookies to inspect the original response. A name can have more than one value, so decide whether the first match is enough.

Cloudflare Rules Set-Cookie Response headers CDN

Service eligibility and regional restrictions

PuppyIP serves only compliant overseas businesses and their authorized personnel. Proxy services are not available in mainland China. The service may only be used for lawful business activities outside mainland China. Use of this service within mainland China is prohibited.

Hosting a proxy IP or server overseas does not change these restrictions. The service must not be provided to end users in mainland China through relaying, forwarding, sharing or resale. Before use, read the Terms of Service.

Key Takeaways

  • Both fields parse the response’s Set-Cookie headers into a map of cookie names to arrays of values.
  • The current field reflects changes from earlier phases. The raw field preserves the original response.
  • Names are URL-decoded and values keep their original encoding. Duplicate names keep their values in order.
  • Availability varies with the feature and plan. Check attributes such as Path, Secure, and HttpOnly separately.

Which response are you trying to inspect?

Start with the question your rule needs to answer. Use raw.http.response.set_cookies to see what the application originally sent. Use http.response.set_cookies when the rule needs to evaluate a response that earlier phases have already processed. Both fields give you the same array format for each name.

Cloudflare keeps field values fixed within a phase. Suppose one response header rule changes Set-Cookie and a later rule in the same phase checks the current cookie field. The later rule cannot see the change from that phase. Find the phase your rule runs in, then compare the original headers, the current field, and the final headers the client receives.

How are duplicate cookie names ordered?

Map keys are URL-decoded cookie names. Names that decode to the same string share an array. Their values appear in header order and remain separate entries. Cookie values themselves are not URL-decoded, so compare a percent-encoded value as it appears in the header.

For a hypothetical test page that sends app=test followed by app=preview, the array for app contains test and preview in that order. Index 0 yields test. If you want to match preview in any position, test it both as the first entry and as the second entry.

Why did a later rule miss a cookie rewritten in the same phase?

Cloudflare evaluates conditions against the field values at the start of a phase. An earlier response header rule can change the headers the client receives, while the next rule in that phase still matches against the cookie value it saw when the phase started.

When troubleshooting, record the original response, the phase that rewrites it, and the phase that reads it. Use Add to append a test cookie. A Set operation on Set-Cookie removes existing response headers with that name and can replace other cookies along with the test one.

How do you verify the match and its scope?

Choose one path on an authorized test host and use a made-up cookie that carries no account, session, or credential data. Have one response return a single app value, one return two app values, and one omit app. Write down the expected match for each response and confirm that the chosen rule supports the response field.

For a visible result, an applicable Response Header Transform Rule can set a fixed test marker when the condition matches. Check that marker and the status at the client. Return the same synthetic cookie from an unrelated path to test the rule’s scope. If earlier phases change the headers, inspect the original and current fields before comparing the full response at the client.

When do you still need the full Set-Cookie headers?

These fields give you cookie names and arrays of values. Path, Secure, and HttpOnly sit outside those arrays, and duplicate values do not carry their individual Path attributes. To verify a credential cookie’s security attributes, distinguish paths for duplicate names, or check browser acceptance, inspect the full headers from a test response and the browser’s cookie state.

Cloudflare documents response field availability by feature and plan. Before moving a test configuration to another rule product, host, or plan, confirm that it supports the same phase and field, then repeat the three synthetic responses.

Sources

Frequently Asked Questions

Can these fields read request cookies?

They read the response’s Set-Cookie headers. For incoming cookies, use the relevant request-side field.

Does the last value automatically replace previous values for the same name?

The rule field preserves all values in occurrence order. To see which cookie the browser stores, check the full headers, the cookies’ scope, and the browser behavior.

Can I verify Secure and HttpOnly in the value array?

Those attributes sit outside the value array. Check the complete Set-Cookie header from an authorized test response.