0

When I try to login as user I have the problem of invalid form key on frontend. Once the page is refreshed, the login works.

We have 4 sites

  1. main.it subdomain.main.it

  2. second.it subdomain.second.it

What could be the cause?

I've tried different setups on the fields -> Cookie path & Cookie Domain

But the problem is always there.

magento 2.4.3

1
  • From my experience this can be caused by a missconfiguration of a punchout module. But it might not be your case there
    – Claims
    Apr 14, 2023 at 13:10

1 Answer 1

0

The "Invalid form key" error in Magento is usually caused by a mismatch between the form key stored in the session and the one submitted with the form. This can happen due to a number of reasons, such as a stale form key in the session, an expired session, or a misconfiguration of Magento's security settings.

Here are some possible solutions you can try:

Clear your browser's cache and cookies, and try again. This will ensure that you have the latest form key from Magento.

Check if your web server's clock is synchronized with the correct time. If the clock is out of sync, it can cause issues with Magento's session management and form key generation.

Make sure that your Magento installation is configured correctly with the correct base URL and secure URLs. You can check this in your Magento Admin Panel under Stores > Configuration > General > Web.

Check if your server has the correct permissions to write to the Magento var/ and generated/ directories. If these directories are not writable, it can cause issues with Magento's session management and form key generation.

If you are using a caching plugin or CDN, try disabling it temporarily to see if it resolves the issue. Sometimes, caching can interfere with Magento's form key generation and validation.

Finally, check if your Magento installation is up-to-date with the latest security patches and updates. Vulnerabilities in older versions of Magento can sometimes lead to issues with session management and form key generation.

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.