Since cookies are small files that are stored in a user’s device to track them on the internet, they have caused many privacy concerns. Cookies serve various purposes, such as remembering user preferences, tracking analytics, etc., and it is crucial to give users control over their cookie preferences.
In this article, you will learn how to properly configure Magento 2 Cookie Restriction Mode to make your website compliant with the regulations.
How to Configure Magento 2 Cookie Restriction Mode
Step 1. Log in to Your Magento 2 Admin Panel
To start with, go to the Magento 2 admin panel and log in with your administrator credentials.
Step 2. Enable & Set Up Magento 2 Cookie Restriction Mode
Once logged in, navigate to “Stores” on the left-hand side of the admin panel and click “Configuration”. Under the “General” section, select “Web” from the dropdown menu. Expand the “Default Cookie Settings” tab and set up the following:
- Cookie Lifetime
Cookie lifetime refers to the duration for which cookies remain stored on a user’s device. The default value is “3600” seconds which is equal to about 1 hour. This means that users will be identified for one hour if they revisit your website. Set to “0” if you want cookies to expire as soon as a user closes their browser. Read more about how to choose the optimal Cookie Lifetime value.
- Cookie Path
To make cookies available for some particular folders on your Magento 2 store, enter the Cookie Path here, for example, “/products/women/”. If you want them to be available anywhere on your site, then enter a forward slash “/”.
- Cookie Domain
Specify your website domain (yourdomain.com) to make the cookies available for all your website. For a specific subdomain only, you need to enter the subdomain name (subdomain.yourdomain.com). If you want to make cookies available to all subdomains, enter the domain name preceded by a period (.yourdomain.com).
- Use HTTP Only
- Cookie Restriction Mode
Set this option to “Yes” to enable the feature and display the cookie notice on the frontend.
Step 3. Clearing Magento Cache and Verifying Configuration
After configuring cookie settings and the Magento 2 Cookie Restriction Mode, it is essential to clear the Magento cache to ensure the updated settings take effect. To clear the cache, go to “System” > “Cache Management” in the man Magento menu, and click “Flush Magento Cache”.
It’s also advisable to clear your browser cache and cookies to see the changes from a user’s perspective.
Here’s what the Cookie Notice looks on the frontend:
In today’s privacy-focused digital landscape, giving users control over their cookie preferences is vital for any online business. With Magento 2’s built-in Cookie Restriction Mode, configuring and managing cookies becomes a straightforward process. By following the steps outlined in this article, you can enable and properly configure Magento 2 Cookie Restriction Mode. Prioritizing user privacy not only ensures compliance with regulations but also fosters trust and enhances the overall user experience on your Magento 2 website.
Additionally, consider using Magento 2 Cookie Consent extension, which provides better options and flexibility for configuring a cookie notice. Unlike built-in Magento functionality, you get compliance with major data privacy laws, such as GDPR in European Union, CCPA in California, LGPD in Brazil, etc., as well as more ways for customization.