Cookies are small text files stored in a web user’s browser directory or data folder that has user’s data like username, password, and browsing history.
Cookies help store owners track the customers’ behaviour and hence enhance their on-site experience.
However, prior to using the customers’ data, it is mandatory to have their consent for the same.
As per the EU’s GDPR, the websites need to have the consent of the users regarding the use of cookies and even allow them to deny using the cookies if they wish. Additionally, when collecting user data for Google’s products(Like GA4 or Google Ads), you must implement Google’s Consent Mode v2 in your store.
Even if your business does not fall under the European Union, asking users for permission to use cookies and notifying them about the privacy policy is not only an ethical practice but also helps win their trust and increase brand loyalty.
Hence, the default Magento 2.4.x versions have introduced the feature to enable cookie restriction mode in Magento 2 store from the backend.
Cookie Notice helps to implement cookie compliance in Magento 2 store. The notification bar displays a cookie restriction message and contains a button “Allow Cookies” as shown below.

When a user accepts the cookie policy, it proceeds further in the store.
Follow the below method to Enable Cookie Restriction Mode in Magento 2.
Method to Enable Cookie Restriction Mode in Magento 2
1. Login to Magento 2 admin panel.
2. Navigate to “Stores > Settings > Configuration”.
3. Expand the “Default Cookie Settings” section.

4. Enter the “Cookie Lifetime” in seconds.
5. Enter the “Cookie Path” if you want to make cookies available to other folders. Enter a forward slash to make the cookies available anywhere on the site.
6. Enter the subdomain name in the “Cookie Domain” field to make the cookies available to a subdomain.
7. Set YES to “Use HTTP Only” to prevent scripting languages from gaining access to cookies.
8. Set YES to “Cookie Restriction Mode”.
9. Save the configuration by clicking the “Save Config” button.
That’s it
Unlock insights while staying within the privacy boundaries
Unlock NowHowever, if you are using older versions of Magento 2 and want to implement cookie notice in your store, you can opt for Meetanshi’s FREE Magento 2 Cookie Notice extension that shows a neat and simple cookie notification bar or popup in the store frontend which can be even customized as per your theme!
Or, if you don’t want to limit to only cookie compliance law but make your Magento 2 store compatible with the GDPR law, have a look at Magento 2 GDPR extension!
Feel free to share the solution with Magento Community via social media.
Thank You.