0

I am testing website deployed based on Magenta Template Framework, the problem that occurred is that the cart kept being empty even the add to cart link has been ran. And furthermore, i kept getting the error "invalid form key please refresh key".

Variable that has been extarcted, PHPSESID, Formkey and coded using cookie manager. Here is the extracted key

The error is still occuring. This is the error i kept getting

3 Answers 3

0

Most probably your JMeter script doesn't provide correct form_key parameter, it is being used by Magento for protection from CSRF attacks so you need to

  1. Extract this form_key value from the previous response and save it into a JMeter Variable
  2. Replace previous (recorded/hard-coded) value with the variable from the step 1

Here how it looks like at i.e. Magento Online Demo instance:

enter image description here

and here is how you can extract it using i.e. CSS Selector Extractor

enter image description here

More information: How to Load Test CSRF-Protected Web Sites

1
  • I have extracted the form key from the main page and insert the form key using the cookie manager. But the error still occured, i have updated my posting with the screenshot.
    – pseudox
    Commented Dec 8, 2020 at 3:33
0

Open the console tab in your browser's developer tools and check if a CORS error has occurred. If there is a CORS error, please add the address to the csp white list... This is the most frequent cause in my case.

0

I had the same problem with magento 2.3, where Add to Cart button refreshed the page instead of adding anything in cart. where as website was working properly in Private Browsing on a custom theme.

Solutions Didn't Worked:

  • Change max_input_var=10000
  • max_input_time = 600
  • max_execution_time = 3600
  • Flush cache

Solution Worked for me:

In Configuration >> Web, I:

I am not sure if its a reliable fix or a temporary, but it resolved the issue for now.

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.