{% set_cookie %}

Sets a cookie on the HTTP response to be returned to the user.

Syntax

{% set_cookie cookieName cookieValue [expires:"date expires"] [path:"/cookie/path"] [domain:".domain.name"] %}

If cookieName starts with '&', it will be treated as a reference variable, which will be dereferenced to the cookie name that will actually be set.

Examples

{% if session.allowed and permissions.allow_public_statistics %}
    {% capture statisticsString -%}
SessionStart: {{session.start_date | date: 'MMMM dd, yyyy, H:mm:ss'}}
SessionRequests: {{session.num_requests}}
LastRequest: {{request.date | date: 'MMMM dd, yyyy, H:mm:ss'}}
<<Add other custom statistics here>>
    {%- endcapture %}
    {% set_cookie site_statistics statisticsString %}
{% endif %}
{% var sectioncookie = 'accountspage' %}
{% var sectioncount = cookies[sectioncookie] | to_int | plus: 1 %}
{% set_cookie &sectioncookie sectioncount %}
{% var expiresDate = "now" | add_minutes: 20 %}
{% set_cookie loginsection "lastsection=accounts" expires:expiresDate path:"/protected" domain:".parentdomain.com" %}

Developer Overview

Liquid Markup