if-cookie-equals
Syntax
if-cookie-equals: (cookie name) "(value)";
This conditional action will return true if the cookie specified equals a value.
Syntax
if-cookie-equals: (cookie name) "(value)";
This conditional action will return true if the cookie specified equals a value.
.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>