Solved – “Your session has expired” On Clicking Add To Cart In Magento 2.3 Localhost
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
1 2 |
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:
1 |
php bin/magento cache:flush |
That’s it.
If you are still stuck with the same error after implementing the above solution, please mention your doubts in the Comments section below. I’d be glad to help you out.
Do share the solution with the fellow developers via social media!
Thanks.
Sanjay 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.
25 Comments
thanks, did work right away, very helpful
Thanks for the appreciation!
After changing localhost to 127.0.0.1/myStoreName/ Its not working for me. Done cache: flush, cache: clean. Need help.
Hello,
Make sure your URL is “http://127.0.0.1/myStoreName/” in core_config_data table.
Thank you.
Hello,
Make sure your URL is “http://127.0.0.1/myStoreName/” in core_config_data table.
Thank you.
Hi, I have this error, unfortunatelly, and can’t solve it 🙁
My localhost address is “http://m235/” , when I work in incognito, all is fine, in FF too, but in chrome on linux – during adding to cart – I have this error:
Your session has expired
Clearing cache, clearing page cache and so on doesn’t help 🙂
Maybe you have any advices?
Hello,
The solution works perfectly.
Also, please recheck your URL as it does not consist 127.0.0.1
Thanks.
It didn’t work for me. It just changed the address the site tried to load at, which didn’t work.
Hey!
Please clear cache and check in the incognito window.
Thanks.
Hello Covich,
Please check after clearing the cache.
Thank You
It worked! Thanks.
I’m glad it was helpful!
Ajudou muito amigo. Obrigado (Awesome bro, thank you ! ).
Thank you!
This worked. Thanks!
Hey Tony, Thanks for the appreciation.
still iam getting the same error can you please help me with this
Hello,
Please clear the cache and try it in incognito mode.
Thank you.
Working…….! Thank you
Welcome 🙂
this working thank so much Dear
Hey,
Thanks for the appreciation!
not worked for me
Hello,
Please clear the cache and check again in the incognito mode.
Thanks.
work like a charm, thanks!