New Fluxzy v2 just shipped. Electron is out, Tauri is in. gRPC ready, 3x smaller install. Learn more

setRequestCookieAction Action

Inject or replace a cookie on the outgoing Cookie header so the upstream service sees a controlled session value without changing the client.

When you need a specific session, bucket, or token on every outgoing request, rewriting the cookie at the proxy is faster than touching the client. setRequestCookieAction keeps the rule contained to the YAML file so reviewers can see exactly what value is being injected and why.

When to use this action

setRequestCookieAction rewrites the outgoing Cookie header so the upstream sees the cookie name and value you specify. The client itself is not modified.

Common use cases:

  • Pin a session cookie when reproducing a bug that only happens for a specific user.
  • Force an A/B test bucket by injecting the cookie that controls feature flags.
  • Bypass a complex login flow by reusing a session token captured from a previous run.

The action runs on the request side. To set a cookie on the response (as if the server had sent it), use setResponseCookieAction.

Real world examples

Pin a session cookie for reproduction

Reuse a captured session token so every request to the API behaves as that specific user, without rerunning the login flow each time.

rules:
- filter:
    typeKind: HostFilter
    pattern: api.internal.example.com
  actions:
  - typeKind: SetRequestCookieAction
    name: JSESSIONID
    value: 9C2A4F0E1B7D88A3F6E0

Force an experiment bucket via a feature flag cookie

Useful for QA of A/B tested features. The cookie value selects the variant, and the client does not need any code change.

rules:
- filter:
    typeKind: HostFilter
    pattern: app.example.com
  actions:
  - typeKind: SetRequestCookieAction
    name: experiment_bucket
    value: variant_b

Add a CSRF token expected by a partner API

Some partner APIs expect a cookie alongside the standard auth header. The action injects it for every request to that host.

rules:
- filter:
    typeKind: HostFilter
    pattern: api.partner.example.com
  actions:
  - typeKind: SetRequestCookieAction
    name: csrf_token
    value: 0a1b2c3d4e5f6a7b8c9d

Reference

setRequestCookieAction

Description

Add a cookie to request. This action is performed by adding/replacing Cookie header in request.

Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

requestHeaderReceivedFromClient This scope occurs the moment fluxzy parsed the request header receiveid from client

YAML configuration name

setRequestCookieAction

Settings

The following table describes the customizable properties available for this action:

Property Type Description DefaultValue
name string Cookie name
value string Cookie value

Example of usage

The following examples apply this action to any exchanges

Add request cookie with name session and value 123456.

rules:
- filter:
    typeKind: AnyFilter
  actions:
  - typeKind: SetRequestCookieAction
    name: session
    value: 123456

.NET reference

View definition of SetRequestCookieAction for .NET integration.

See also

The following actions are related to this action:

Frequently asked questions

Does this replace or merge with existing cookies?

If a cookie with the same name already exists in the request, its value is replaced. Other cookies on the same header are preserved.

Can I set multiple cookies at once?

Yes. Add several setRequestCookieAction entries under the same actions list. Each entry handles a single cookie by name.

Does the client see the rewritten cookie?

No. The action runs on the proxy after the client has sent the request. The client is unaware of the rewrite, which is often the whole point.

What if the cookie contains characters that need encoding?

Encode the value yourself before putting it in the YAML rule. Fluxzy writes the value into the header verbatim.

Learn more about Fluxzy rules