{{ cookies }}

The cookies object is available on every page, and contains information regarding the cookies sent with the request. Note that this will typically only include cookies for the current or top-level domain on multi-domain sites.


string object_type
Will always be "cookies".
true/false is_valid
Will always be true.

Individual cookies on this request may be accessed using {{ cookies.cookieName }} or {{ cookies['cookieName'] }} syntax.

You may also treat this object as a list containing all of the cookies which may be iterated using a {% for %} loop. For more details, see the examples below:


{% if cookies.customCookieName %}
    {% assign cookieValue = cookies.customCookieName %}
{% elsif cookies['alternate-cookie-name'] %}
    {% assign cookieValue = cookies['alternate-cookie-name'] %}
{% endif %}
{% if cookieValue != empty %}
    <p>Do something with {{ cookieValue }}</p>
{% endif %}

To list all of the cookies in the current request:

{% for cookie in request.cookies %}
    <li><strong>{{cookie}}</strong> = {{cookies[cookie]}}</li>
{% endfor %}

Developer Overview

Liquid Markup