The docs state that {{ craft.request.getCookie(name) }} will not work for cookies that were set in JavaScript, because all cookies in Craft go through some validation to ensure that they aren't tampered with.

This is understandable, but is there any way of getting non-Craft cookies with twig?

2 Answers 2


So far the only solution I have found is to use a plugin, and Lewis Jenkins' LJ Cookies plugin does the trick nicely:

{{ craft.lj_cookies.get( NAME ) }}

It also allows you to set and delete cookies within templates.

  • 1
    It really bugs me that I have to have a whole plugin just to access a cookie set from JS. That's a very "Wordpress" solution to a problem. The Craft guys need to figure out a correct way to do this. Given how ajax heavy most sites are it's a super common way to set cookies. Not much good if you can't get the values back.
    – JamesNZ
    May 2, 2017 at 22:05
  • Please update the LJ Cookies Plugin Github Repo to github.com/khamer/craft-lj-cookies Mar 28, 2020 at 5:15
  • Updated, thanks!
    – Ben Croker
    Mar 28, 2020 at 18:12

For now, you have to use a plugin

I recommend one of these 2

  1. Craft Cookies Plugin https://github.com/nystudio107/craft-cookies
  2. Craft LJ Cookies Plugin https://github.com/khamer/craft-lj-cookies

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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