{% unset_cookie %}

"Unsets" a cookie (due the nature of cookies, this will actually ADD the cookie to the response but the cookie expiration date will be in the past).

Syntax

{% unset_cookie cookieName1 [cookieName2] [etc...] %}

You may also include reference variables, which will be dereferenced to their cookie names before unsetting the cookies.

There is no option to unset all cookies - cookies must be individually removed.

Examples

Unset Cookie

Copy
{% if cookie.advertising_id %} {% unless permissions.allow_advertising %} {% unset_cookie advertising_id advertising_alt_id %} {% endunless %} {% endif %}

Unset multiple Cookies

Copy
{% var unset_cookies = request.query_params.unsetcookies | split: ',' %} {% for cookie in unset_cookies %} {% var cookie_alt = cookie | append:'-alt' %} {% unset_cookie &cookie &cookie_alt %} {% endfor %}