I am working on a site where i'm implementing my own cookie bar module. For this module i have made it possible to write something in the CKeditor like:

enter image description here

Where everything between the {cookie} tags is only visible when cookies are accepted. This works fine on my dev environment, but when I deployed it to the test server where cache is enabled it won't show any change when you enable/disable cookies because the page is already cached.

Is there a way to disable cache on the text field or better yet, everything between the cookie tag?

1 Answer 1


You need to adjust the cache context of the node.

If the cookie is a drupal session, use the predefined cache context for this:

$build['#cache']['contexts'][] = 'session.exists';

If you target another cookie, that drupal is not aware of, you would need to create your own context, more info:


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.