How to show or access cookie values in Symfony Twig views

Strange how obscure it is to find a clear example of how to just access or show the value of a cookie in Twig, so here it is!

{{      app.request.cookies.get('yourCookieHere')  }}

Twig is the templating engine that powers Symfony views.  Symfony is the PHP framework from Sensio Labs.

If you are a company that uses open-source software and developers and you are not using a PHP framework, you should consider migrating your legacy “cowboy” code to a collaborative, scalable framework like Symfony before it becomes a necessity for your company.  I have overseen many migrations of systems and data over the years and am available for consultation at my business consulting site at Belchamber.us.

– Aaron Belchamber

About Author:

Senior Cloud Software Engineer and 25+ years experienced video production, video editing and 3D animation services for a variety of global clients including local video production here in Jacksonville, Florida.

Leave a Comment

Your email address will not be published. Required fields are marked *