SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH SPECIAL OFFER: ENJOY 3 MONTHS OF SHOPIFY FOR $1/MONTH

How to fix the error the store will not work correctly in the case when cookies are disabled

When I upgraded my website from M2.3.5 to M2.4.2, I get this notice “The store will not work correctly in the case when cookies are disabled.” on top of the head frontend for 3 seconds. But I installed a new M2.4.2 have not to get that notice(Cookie Restriction Mode = No). I found a div id named “cookie status” The store will not work correctly in the case when cookies are disabled. but I can’t find which file can control this. I don’t need the notice display, so how to do that?

Today I will guide you:

Did disable in the Default cookie settings.

It’s taking time to hide because there is using js for hide. you can use css for hide instaed of $script = ‘document.querySelector(“#cookie-status”).style.display = “none”;’;

Content comes from vendor/magento/module-theme/view/frontend/templates/js/cookie_status.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>

<div id="cookie-status">
    <?= $block->escapeHtml(__('The store will not work correctly in the case when cookies are disabled.')); ?>
</div>
<?php
$script = 'document.querySelector("#cookie-status").style.display = "none";';
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', ['type' => 'text/javascript'], $script, false); ?>

<script type="text/x-magento-init">
    {
        "*": {
            "cookieStatus": {}
        }
    }
</script>

save and clear the cache, reload the web page and everything is solved.