Zeusox
Zeusox

Reputation: 8458

Is there any way to use Cookies in Shopify Liquid templates?

I am setting up a cookie inside a script file; however, I do not seem to find any working way to grab the value of that cookie and compare it against another value using Shopify liquid if statements?

For example,

I have a cookie set as: customer_email: '[email protected]'.

I would like to grab this cookie value somehow and compare it using Shopify's if statement as below:

{% if customer_email == '[email protected]' %}

   DO SOMETHING

{% endif %}

Upvotes: 2

Views: 5966

Answers (1)

BluLotus
BluLotus

Reputation: 159

It's not possible to read cookies from Liquid. But you can read the value client-side with JavaScript in the Liquid template.

Upvotes: 2

Related Questions