Set and access cookie values
You can set cookie values to use on your site, or you can access cookie values that are set with Javascript. Below are some examples.
Get a cookie value.
{{ _page.cookies.myCookie }}
Test for a cookie value.
{% if _page.cookies.myCookie %}
{% endif %}
or
{% if _page.cookies.myCookie is defined %}
{% endif %}
Test to see if a cookie is not set,
{% if _page.cookies.myCookie is not defined %}
{% endif %}
Set a cookie value.
{% set _page.cookies.myCookie = 'cookie value' %}
Set a cookie value with expiration data.
{% do _page.cookies.set('myCookie', 'cookie value', '1000') %}
Chain set multiple cookie values.
{% do _page.cookies.set('anotherCookie', 'Cookie Value', 1000).set('chaincookie', 'chain cookie value') %}