{{ cookies }}

{{ 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.

Properties

Field Type Description
object_type string Will always be "cookies".
is_valid true/false Will always be true.
cookiename string The name of the cookie used for storing permissions. Will always be "_mp_permissions".

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:

Examples

Access custom cookie

Copy
{% if cookies.customCookieName %} {% assign cookieValue = cookies.customCookieName %} {% elsif cookies['alternate-cookie-name'] %} {% assign cookieValue = cookies['alternate-cookie-name'] %} {% endif %} {% if cookieValue != empty %}

Do something with {{ cookieValue }}

{% endif %}

List all cookies in the current request

Copy

Cookies:

    {% for cookie in request.cookies %}
  • {{cookie}} = {{cookies[cookie]}}
  • {% endfor %}