There are no tracking or monitoring cookies on this site. There are only cookies used for documentation examples related to cookies.
Close

Processing...
This may take a few seconds.

if-cookie-equals

Syntax

if-cookie-equals: (cookie name) "(value)";

This conditional action will return true if the cookie specified equals a value.

if-cookie-equals

.cookieEqualsButton1:click {
    set-cookie: name(cookieNoticeSeen) value("{@data-ref}") expires("Year") path("/") sameSite("Strict") secureIfHttps;
}

#cookieEqualsButton2:if-cookie-equals(cookieNoticeSeen "y"):click {
    #cookieEqualsMessage {
        render: "cookieNoticeSeen is set to 'y'.";
    }
}

#cookieEqualsButton2:if-cookie-equals(cookieNoticeSeen "n"):click {
    #cookieEqualsMessage {
        render: "cookieNoticeSeen is set to 'n'.";
    }
}
<p><button class="cookieEqualsButton1" data-ref="n">Set cookie to "n"</button>
<button class="cookieEqualsButton1" data-ref="y">Set cookie to "y"</button></p>

<button id="cookieEqualsButton2">Show updated value</button>

<p id="cookieEqualsMessage"></p>