In your Magento 2 journey, you might have greeted with this error message – “Your session has expired”, when clicking on the add to cart button.
This is usually happen when you install Magento in your machine and give the url as localhost.
To resolve the issue you can change the unsecure/secure baseurl to 127.0.0.1 in your Magento 2 installation.
Open your database in your favorite tool like phpmyadmin and run the below MySql query.
UPDATE core_config_data SET value = 'http://127.0.0.1/magento2/' WHERE core_config_data.path = 'web/unsecure/base_url'; UPDATE core_config_data SET value = 'http://127.0.0.1/magento2/' WHERE core_config_data.path = 'web/secure/base_url';
And clear your cache, you will see the error is gone.
php bin/magento cache:flush