ActiveCampaign
Also available forKeap

[memb_if_cookie]

Summary
Displays content to a user based on their cookies.

Description

This is a conditional shortcode that checks whether a $_COOKIE variable exists or matches a specific value, then displays content accordingly. It uses an [else_memb_if_cookie] block for the fallback when the condition is not met.

Shortcode Examples

Check if a cookie named member_type equals premium:

[memb_if_cookie key="member_type" test="=" value="premium"]
    Welcome, Premium member!
[else_memb_if_cookie]
    Upgrade to Premium for exclusive content.
[/memb_if_cookie]

Check if a cookie exists at all:

[memb_if_cookie key="returning_visitor"]
    Welcome back!
[else_memb_if_cookie]
    First time here? Check out our getting started guide.
[/memb_if_cookie]

Check if a cookie value is in a list:

[memb_if_cookie key="plan" test="in" value="gold,silver,bronze"]
    Your plan includes this feature.
[else_memb_if_cookie]
    This feature requires a paid plan.
[/memb_if_cookie]

Shortcode Parameters

key(Required) The cookie name to check.
test(Optional) Comparison operator. Default: =. Valid operators: =, ==, ===, eq, ne, !=, !==, gt, >, lt, <, ge, >=, le, <=, bw (begins with), ew (ends with), contains, in, !in, range, !range.
value(Optional) The value to compare against. If omitted and test is empty, checks for the key’s existence only.
caseinsensitive(Optional) Whether to perform a case-insensitive comparison. Default: true.
captureCaptures the shortcode output and routes it to a variable for later use.
txtfmt(Optional) Comma-delimited list of text processing functions to apply to the output.

Additional Information

The key parameter refers to the cookie name. If value is omitted and test is empty, the shortcode checks for the cookie’s existence only. Cookie availability depends on the cookie’s path and domain settings—a cookie set for a subdomain or specific path may not be visible on the current page.

Shortcode Attributes

ConditionalYes
NestableYes
Accepts formattingYes
CapturableYes