2

This question was already asked a few years ago, and the way of doing it was through a plugin. I was wondering if there is a way of doing it just using Craft and Twig.

I set up a cookie using JavaScript, and I want to read it with Craft. Is this possible?

2

Assuming this is for Craft 3, you can do something like this from a template to loop through all available cookies for a site:

{% set cookies = craft.app.request.getCookies() %}

{% for cookie in cookies %}
    {{ cookie.name }}
{% endfor %}
0

That seems to work, but I get back 'CRAFT_CSRF_TOKEN'. I am expecting another value.

{% set cookies = craft.app.request.getCookies('invited') %}

I'm requesting the cookie like that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.