3

I've started out with Magento 2. Everything's working fine, except for Magento's formKeyValidator which isn't able to validate the incoming request. It's happening on the frontend.

While adding a product to the cart or creating an account. This isn't passing::

// module-checkout/Controller/Cart/Add.php - function execute()
$this->_formKeyValidator->validate($this->getRequest())

I've increased the cookie lifetime, set the valid domain, and path ( http://localhost/mysite, domain:localhost, path:/mysite ) from the backend config panel, yet for some reason I keep getting this:

"Your session has expired"

2

2 Answers 2

16

Yes, use 127.0.0.1 instead of localhost.

UPDATE `core_config_data` SET `value` = 'http://127.0.0.1/magento/' WHERE `core_config_data`.`path` = 'web/unsecure/base_url';
UPDATE `core_config_data` SET `value` = 'http://127.0.0.1/magento/' WHERE `core_config_data`.`path` = 'web/secure/base_url';
3
  • Thanks. I actually solved it the same day when I fist posted it. This answer might help others. Commented Jan 29, 2019 at 16:27
  • I tried but not working. Commented Jul 16, 2019 at 11:22
  • Thanks @jean works for me Commented Sep 3, 2020 at 11:45
5

Step 1: Disable the cache
Steps 2: Run below two lines of Mysql code

UPDATE `core_config_data` SET `value` = 'http://127.0.0.1/yourmagentofolder/' WHERE `core_config_data`.`path` = 'web/unsecure/base_url';
UPDATE `core_config_data` SET `value` = 'http://127.0.0.1/yourmagentofolder/' WHERE `core_config_data`.`path` = 'web/secure/base_url';

Not the answer you're looking for? Browse other questions tagged or ask your own question.