Magento – Magento2: Minicart is full while Cart is Empty

cartcheckoutcheckoutsessioncookiemagento-2.1.7

A lot of our customers are complaining that they add stuff to the cart & then when they proceed to checkout they are redirected to an empty cart.
We thought that it might be a result of too short session time, so we tried increasing the cookie/session lifetime to 86400 (on both admin & server).
After that, I tried to reproduce the problem & managed to achieve the weird behavior as you can see on the attached screenshot.

I added products to cart, came back after about 20-30 minutes & saw my items in the minicart. then I proceeded to checkout & it redirected me to this empty cart while the minicart is still showing my items (refreshing the page also didn't work):
enter image description here

— Any Idea?


UPDATE: So far we managed to solve this issue by changing back the session configuration to use files (disabled Memcached). I know that Magento recommends using Memcached & have no idea what caused this issue…

Best Answer

app\code\Vendor\Extension\etc\frontend\section.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="extension/controller/action">
        <section name="cart"/>
    </action>
</config>

In this action parameter name, you have to pass the full action (For ex. checkout/cart/add ) in which cart is updated. It means you programmatically delete or add a product to cart to the shopping cart.

Lastly, Comment down below if you face any issue while using this code.

Happy Coding!