I see that in magento 2 form_key is set in cookies. Is this cookie present in every page?

  • I can say yes. We can find the form_key in cookie in every page. – Khoa TruongDinh May 30 '17 at 14:33
  • Well i agree that it appears in pages. But do you what code renders it? – Moshe Shperling May 30 '17 at 14:47
  • Should take a look: vendor/magento/framework/App/PageCache/FormKey.php, vendor/magento/module-page-cache/Observer/RegisterFormKeyFromCookie.php – Khoa TruongDinh May 30 '17 at 14:50

I can say yes. We can find the form_key in cookie on every page.


<event name="controller_action_predispatch">
    <observer name="register_form_key"

As we can see, for each Action Dispatch request, Magento will try to register the form key from the cookie.

  • It works with varnish? It can't cache the page if page sets always the cookie right? – Wiliam Nov 27 '17 at 18:50

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.