I have serious problems with custom Magento 2 theme and (probably) formkey cashing. I have 2 views of exactly same e-shop.

 - View 1: Luma Theme
 - View 2: Custom Theme (Luma child) - overriding layouts, phtml, styles and javascripts

If cache is enabled and flushed everything -> adding/deleting from car works properly. After several minutes specified actions in View 2 (Custom theme) returns 302 status code and Magento redirects user to /cart page.

Now i discovered 3 ways how to "fix" this issue.

  1. Flush cache - only temporary solution for few minutes.
  2. Delete formKey validation from Magento core - totally inappropriate.
  3. Disable cache - affects performance.

I'm struggling with this problem couple of days and I will be glad for any advice.

  • You're trying localhost as the top level domain? – Khoa TruongDinh Jul 5 '17 at 4:58
  • No, tld is eu or dev. View 1 with Luma works propertly. – Higi Jul 7 '17 at 5:42

Magento 2 - invalid form key occurs before of 2 reasons.

1) check your view source page, generated form_key and passing form_key are same. if not same need to fix it.

2) increase php_value max_input_vars 75000. Check your error log surely max_input_vars reached error will through.

Hope it will helpful for you

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.