Cookies are the easiest way to identify sessions, feature flags, and tracking state in real traffic, and the hasCookieOnRequestFilter lets you select exchanges by cookie name with the same level of control you get from a regex search. Combine it with rewrite or tagging actions to keep noisy state under control during a debug session.
Reach for hasCookieOnRequestFilter when a rule should only fire on requests that send a particular cookie. You can match by name only, or narrow further with a value pattern, supporting exact, contains, startsWith, endsWith, and regex operations.
Practical uses:
JSESSIONID or PHPSESSID.Mark every exchange that sends a JSESSIONID cookie so you can filter or export them later.
rules:
- filter:
typeKind: HasCookieOnRequestFilter
name: JSESSIONID
pattern: ''
operation: Regex
actions:
- typeKind: ApplyTagAction
tag:
value: java-session
Trigger only when the cookie value indicates the user is in a specific cohort.
rules:
- filter:
typeKind: HasCookieOnRequestFilter
name: ab_cohort
pattern: experiment-b
operation: Exact
caseSensitive: true
actions:
- typeKind: AddRequestHeaderAction
headerName: x-cohort-debug
headerValue: experiment-b
Rewrite the cookies so the chosen tracking ID never reaches the upstream server.
rules:
- filter:
typeKind: HasCookieOnRequestFilter
name: _ga
pattern: ''
operation: Regex
actions:
- typeKind: SetRequestCookieAction
name: _ga
value: ''
Exchange having a request cookie with a specific name
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
hasCookieOnRequestFilter
The following table describes the customizable properties available for this filter:
| Property | Type | Description | DefaultValue |
|---|---|---|---|
| name | string | Cookie name | |
| pattern | string | The string pattern to search | |
| operation | exact | contains | startsWith | endsWith | regex | The search operation performed | contains |
| caseSensitive | boolean | true if the Search should be case sensitive | false |
| inverted | boolean | Negate the filter result | false |
The following examples apply a comment to the filtered exchange
Select only filter having a request cookie with name JSESSIONID.
rules:
- filter:
typeKind: HasCookieOnRequestFilter
name: JSESSIONID
pattern: ''
operation: Regex
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
View definition of HasCookieOnRequestFilter for .NET integration.
The following filters are related to this filter:
Leave pattern empty and set operation: Regex. An empty regex matches any value, so the filter triggers whenever the named cookie is present.
Cookie names follow HTTP semantics. The filter compares them case sensitively against the request, so spell the name exactly as the client sends it.
Stack multiple hasCookieOnRequestFilter blocks inside a FilterCollection with an And or Or operation to combine cookie checks.