I am trying to show or hide a block based on a cookie. The cookie is set on a form submission and whether the user sees the block depends on if they have the cookie set. I have it working but when Full Page Cache is enabled it ignores the cookie and just shows whatever is in the cache.

At it's most basic I have the following at the top of the block phtml:


// else show the block content.

I don't want to use cacheable=false for obviously reasons.

I have considered using private content to "Hole punch" but I don't need to display personal content, just the block itself. Any suggestions on how best to achieve this?


1 Answer 1


I would suggest using something called HTTP context. It allows you to have multiple versions of the same page but still serve it via FPC. For example it’s used to show different prices to different customer groups who have catalog price rules.

Take a look here for how to achieve it 🙂 https://www.atwix.com/magento-2/cache-context-and-page-variations-in-magento-2/

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.