Magento 2.2.7 Session Expired – How to Fix ‘Your Session Has Expired’ Issue

magento2validation

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"

Best Answer

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';
Related Topic