🔥 Just Launched! Werra Premium Template for HyväSee it in Action

Solved – “Your session has expired” On Clicking Add To Cart In Magento 2.3 Localhost

By Sanjay JethvaUpdated on May 22, 2025 1 min read

If you have been too much into Magento like me, you might have experienced an error that says “Your session has expired” on clicking add to cart in Magento 2.3 localhost.

This may happen when you have installed a fresh Magento 2.3 at local and trying test product functionality by adding to the cart.

To resolve the issue, try the below solution to get rid of the expired session error.

Solution For “Your Session Has Expired” On Clicking Add To Cart In Magento 2.3 Localhost:

Use 127.0.0.1 instead of localhost

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

“http://127.0.0.1/mag233sample/” is localhost homepage URL

Run the command:

php bin/magento cache:flush

That’s it.

Do share the solution with the fellow developers via social media!

Thanks.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.