How to Configure Magento 2 Cookies?

How to Configure Magento 2 Cookies?

Configuring Magento cookies enables store owners to monitor customer behavior and improve their on-site experience. Cookies are small text files in a web user's browser directory or data folder. It contains user data such as usernames, passwords, and browsing history.

This tutorial will walk you through the steps to configure Magento 2 cookies for an enhanced user experience and compliance. It will also explain how to edit cookie policies and messages.

Key Takeaways

  • Discover the importance of Magento cookies in optimizing cookie configurations supporting e-commerce functionalities for enhanced user data protection.

  • Discover how to configure Magento 2 cookies for enhanced user experiences by setting cookie lifetimes, paths, and domains in the admin panel's settings.

  • Explore the process of editing cookie policies and messages to align with privacy regulations like GDPR, ensuring ethical user consent for cookie usage.

  • Learn how to implement Magento 2's Cookie Restriction Mode to prompt cookie consent banners, allowing improved browsing experiences.

  • Explore troubleshooting tips, including clearing browser caches, validating Admin server configurations, and checking extension compatibility to ensure cookie functionality.

What are Cookies?

Overview of cookies in Magento 2 for user experience enhancement

Cookies in Magento 2 are small data generated by websites and stored on your computer. It retains information about users' online sessions, such as their navigation history and page visits. Cookies are primarily used to customize user experiences and provide recommendations based on their previous actions. They also facilitate users in resuming their activities.

For store owners, cookies are a valuable tool to track customers' website journeys and inform their strategies. According to the EU's GDPR, websites must obtain user consent for cookies and provide an option to refuse them.

Even if your business operates outside the European Union, seeking user permission to use cookies and informing them about privacy policies is ethical. It is a means to build trust and enhance brand loyalty. A pop-up message may appear in certain regions, requesting users to allow cookies before enabling certain operations.

Default Magento 2.4.x versions have enabled cookie restriction mode in the Magento store's backend settings. The Cookie Notice feature aids in implementing cookie compliance within your Magento 2 store. It displays a notification bar with a cookie restriction message and an "Allow Cookies" button.

Steps to Configure Cookies in Magento 2

  1. Log in to your Magento 2 admin panel.

  2. Go to Stores > Settings > Configuration.

  3. Expand the Default Cookie Settings section.

Guide to accessing default cookie settings in Magento 2 admin panel

  1. Specify the Cookie Lifetime in seconds, determining how long cookies remain on a user's computer. The default is 3600 seconds, roughly 1 hour. To make cookies expire when the user closes their browser, select 0.

  2. Enter a Cookie Path with a forward slash (/) to make cookies available in other folders.

Configuring cookie lifetime and path for Magento 2 stores

  1. To make cookies accessible to a subdomain, input the subdomain name in the Cookie Domain field. Use the format with a preceding period to enable cookies across all subdomains.

  2. Ensure Use HTTP Only is set to YES to restrict access to cookies solely via the HTTP protocol, preventing other protocols like JavaScript.

  3. Set Cookie Restriction Mode to YES.

Steps to activate Cookie Restriction Mode in Magento 2

  1. Save your configuration by clicking the Save Config button.

  2. Clear the Magento cache.

Steps to Edit Cookie Policy in Magento 2

  1. Access the admin panel and navigate to Content > Elements > Pages.

Navigating to pages for cookie policy editing in Magento 2

  1. Locate the Privacy Policy page and choose Edit from the Action dropdown menu.

  2. Select the relevant Magento store view and set the status to Enabled.

  3. Proceed to the Content tab to make the necessary updates to your Privacy Policy.

Editing cookie policy in the Content tab of Magento 2

  1. In the Page in Websites section, designate the Store View where this page should be displayed.

Configuring Page settings for cookie policy in Magento 2

  1. Save your changes by clicking the Save button.

  2. Verify your Magento storefront's updated privacy policy page, where it will now be visible.

Display of updated privacy policy page in Magento 2

How to Update Magento Cookie Message

  1. Access the Magento Admin panel and navigate to Content > Elements > Pages.

  2. Locate the Enable Cookies page and select Edit from the Action dropdown.

Editing process for updating Magento cookie message

  1. Enable the page and specify the store views where you want to apply it.

  2. Adjust the cookie message in the Content section.

Adjusting cookie message in the content section of Magento 2

  1. In the Page in Websites section, choose the Store View where the message should be displayed.

Configuring store view for updated cookie message in Magento 2

  1. Once you've made the desired updates, save your changes by clicking the Save button.

Troubleshooting Tips for Configuring Magento 2 Cookies

  1. Admin Access: Ensure you have administrative access to configure cookies within Magento 2. Verify your Magento login credentials and associated permissions.

  2. Clear Browser Cache: Resolve potential login or display problems within the admin panel by clearing your web browser's cache and cookies.

  3. Review Configuration Steps: Double-check the accuracy of each configuration step, with a specific focus on elements such as cookie lifetime, path, and domain settings.

  4. Magento Version Compatibility: Confirm alignment of the configuration steps with your specific Magento version. Instructions may vary based on your Magento 2 version.

  5. Browser Compatibility Testing: Confirm consistent functionality of cookie settings across various web browsers to ensure cross-platform compatibility.

  6. Server Configuration Validation: Validate the correct configuration of your web server, ensuring compliance with Magento 2 server requirements. Verify the absence of server-related issues impacting cookie functionality.

  7. Third-party Extension Examination: When utilizing third-party Magento extensions, ascertain their compatibility with your Magento version. Additionally, check for potential conflicts with cookie settings. Temporary extension deactivation can aid in conflict identification.

  8. Cookie Notice Display: If the cookie notice fails to appear as expected, reevaluate the Cookie Restriction Mode setting to ensure it is configured as YES.

  9. Magento Cache Clearance: Address issues concerning changes not reflecting by clearing the Magento cache. Access System > Cache Management and select Flush Magento Cache.

  10. Logging and Error Message Analysis: Examine Magento log files for Magento error messages or issues related to cookie configuration. This examination can provide valuable insights for issue resolution.

  11. Community Assistance: When troubleshooting becomes challenging, seek guidance from the Magento community forums. Consult Magento hosting experts for assistance in addressing specific issues.


1. What are the benefits of configuring cookie files in Magento 2?

Configuring cookie files in Magento 2 offers general advantages like enhanced tracking of user sessions and improved e-commerce functionalities. It enables tracking user behavior, aiding in personalized shopping experiences.

2. How can I customize the cookie banner in Magento 2?

To customize the cookie banner in Magento 2, navigate to the backend, access the content manager, and modify the cookie notice. You can adjust the text, link it to your privacy policy, and choose where it is displayed on the frontend.

3. What is Magento 2's Cookie Restriction Mode, and how does it work?

Magento 2's Cookie Restriction Mode ensures compliance with GDPR and other regulations. It prompts a cookie consent banner, allowing users to give their consent. This feature restricts certain functionalities until users agree to the cookie policy.

4. Can Magento 2 cookies be configured for specific domains or subdomains?

Yes, Magento 2 allows configuring cookies for specific domain names and subdomains. By appropriately setting the cookie domain in the Magento configuration settings, cookies can be accessible across the main domain and its subdomains.

5. Is there a method to disable cookie notifications in Magento 2?

Yes, users can opt-out or disable cookie notifications in Magento 2 by choosing not to consent to the cookie policy displayed in the banner. This action may restrict access to certain features until users agree to accept cookies.

6. How do Magento 2 cookies enhance the customer browsing experience?

Magento 2 cookies play a pivotal role in enhancing the browsing experience for customers. They aid in session persistence, allowing customers to resume shopping from where they left off. This customization based on browsing history and analytics contributes to a more personalized shopping journey.

7. Can Magento 2 extensions affect cookie settings in browsers?

Yes, Magento 2 extensions might impact cookie settings in browsers. Some extensions might introduce additional cookies or modify existing ones to enhance functionalities or analytics. Reviewing extension details and their impact on cookies is advisable to ensure compliance and a consistent user browsing experience.


Configuring Magento 2 cookies involves setting parameters for session persistence, user tracking, and compliance with regulations like GDPR. This tutorial covered essential steps to configure Magento 2 cookies. It covered steps to enable Cookie Restriction Mode, edit cookie policies, and update cookie messages.

Explore various Magento server hosting options to ensure seamless implementation of cookie configurations, enhanced user experience, and compliance with e-commerce regulations.

Maria Ajnawala
Maria Ajnawala
Technical Writer

Maria has over five years of expertise in content marketing, specialising in Magento insights and industry trends. She excels in creating engaging content that resonates within the Magento community.

Get the fastest Magento Hosting! Get Started