Set_cookie

Set_cookie

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 %}

Set Cookie that expires in 20 minutes

Copy
{% var expiresDate = "now" | add_minutes: 20 %}
{% set_cookie loginsection "lastsection=accounts" expires:expiresDate path:"/protected" domain:".parentdomain.com" %}

Set cookie with reference variable

Copy
{% var sectioncookie = 'accountspage' %}
{% var sectioncount = cookies[sectioncookie] | to_int | plus: 1 %}
{% set_cookie &sectioncookie sectioncount %}