diff --git a/vendor/magento/module-customer/view/frontend/web/js/customer-data.js b/vendor/magento/module-customer/view/frontend/web/js/customer-data.js
index 97656f9f498d..06c5a5eaac37 100644
--- a/vendor/magento/module-customer/view/frontend/web/js/customer-data.js
+++ b/vendor/magento/module-customer/view/frontend/web/js/customer-data.js
@@ -48,9 +48,10 @@ define([
      */
     invalidateCacheByCloseCookieSession = function () {
         if (!$.cookieStorage.isSet('mage-cache-sessid')) {
-            $.cookieStorage.set('mage-cache-sessid', true);
             storage.removeAll();
         }
+
+        $.cookieStorage.set('mage-cache-sessid', true);
     };

     dataProvider = {
