{"id":1633,"date":"2021-03-03T09:30:07","date_gmt":"2021-03-03T09:30:07","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/enable-cookie-restriction-mode-in-magento-2\/"},"modified":"2025-07-24T15:19:11","modified_gmt":"2025-07-24T09:49:11","slug":"enable-cookie-restriction-mode-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/enable-cookie-restriction-mode-in-magento-2\/","title":{"rendered":"How to Enable Cookie Restriction Mode in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Cookies are small text files stored in a web user\u2019s browser directory or data folder that has user\u2019s data like username, password, and browsing history.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cookies help store owners track the customers\u2019 behaviour and hence enhance their on-site experience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, prior to using the customers\u2019 data, it is mandatory to have their consent for the same.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As per the&nbsp;<a href=\"https:\/\/gdpr.eu\/\" target=\"_blank\" rel=\"noreferrer noopener\">EU\u2019s GDPR<\/a>, 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\u2019s products(Like GA4 or Google Ads), you must implement Google\u2019s&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-google-consent-mode.html\">Consent Mode v2<\/a>&nbsp;in your store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hence, the default Magento 2.4.x versions have introduced the feature to&nbsp;<em><strong>enable cookie restriction mode in Magento 2<\/strong><\/em>&nbsp;store from the backend.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cookie Notice helps to implement cookie compliance in&nbsp;Magento 2&nbsp;store. The notification bar displays a cookie restriction message and contains a button \u201cAllow Cookies\u201d as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/Screenshot-at-March-1st-2021-5.41.24-pm-1024x512.png\" alt=\"Cookie restriction Message\" class=\"wp-image-13625\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When a user accepts the cookie policy, it proceeds further in the store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Follow the below method to&nbsp;<em><strong>Enable Cookie Restriction Mode in Magento 2.<\/strong><\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Enable Cookie Restriction Mode in Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">1. <strong>Login<\/strong>&nbsp;to Magento 2 admin panel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Navigate to \u201c<strong>Stores<\/strong>&nbsp;&gt;&nbsp;<strong>Settings&nbsp;<\/strong>&gt;&nbsp;<strong>Configuration\u201d.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. Expand the \u201c<strong>Default Cookie Settings\u201d<\/strong>&nbsp;section.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/Screenshot-at-March-1st-2021-5.40.44-pm-1024x508.png\" alt=\"cookie configuration\" class=\"wp-image-13627\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">4. Enter the \u201c<strong>Cookie Lifetime\u201d<\/strong>&nbsp;in seconds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5. Enter the \u201c<strong>Cookie Path\u201d&nbsp;<\/strong>if you want to make cookies available to other folders. Enter a forward slash to make the cookies available anywhere on the site.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6. Enter the subdomain name in the<strong>&nbsp;\u201cCookie Domain\u201d&nbsp;<\/strong>field to make the cookies available to a subdomain.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">7. Set YES to \u201c<strong>Use HTTP Only\u201d&nbsp;<\/strong>to prevent scripting languages from gaining access to cookies.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">8. Set YES to \u201c<strong>Cookie Restriction Mode\u201d.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">9. Save the configuration by clicking the<strong>&nbsp;\u201cSave Config\u201d<\/strong>&nbsp;button.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><div class=\"meetanshi-cta\">\r\n<div class=\"cta-content-wrapper\">\r\n<span>Magento 2 Google Consent Mode v2<\/span>\r\n<p>Get customer insights while staying within the privacy boundaries.<\/p>\r\n<a href=\"https:\/\/meetanshi.com\/magento-2-google-consent-mode.html\" target=\"_blank\" class=\"btn-primary\">Get Now <\/a>\r\n<\/div>\r\n<div class=\"cta-image-new\">\r\n<img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2025\/11\/google-consent-mode-v2.png\" alt=\"Magento 2 Google Consent Mode v2\">\r\n<\/div>\r\n<\/div><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, if you are using older versions of Magento 2 and want to implement cookie notice in your store, you can opt for Meetanshi\u2019s FREE&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-cookie-notice.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Cookie Notice<\/a>&nbsp;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!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Or, if you don\u2019t want to limit to only cookie compliance law but make your Magento 2 store compatible with the GDPR law, have a look at&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-gdpr.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 GDPR<\/a>&nbsp;extension!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the solution with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cookies are small text files stored in a web user\u2019s browser directory or data folder that has user\u2019s data like username, password, and browsing history&#8230;.<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1633","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1633"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1633\/revisions"}],"predecessor-version":[{"id":14467,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1633\/revisions\/14467"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}