Hello Magento Friends,
A cookie is a small piece of information stored in a user’s computer when the user is browsing any website via web browsers. After then the user can retrieve those data as and when required. Cookies are generally used to provide a personalized user experience by tracking user’s actions.
Step 1: First Create a JS file in your extension or theme. To do this, create customcookie.js in
function ($, Component)
initialize: function ()
this.cookieMessages = $.cookieStorage.get('mage-string');
To use this feature, we have to add both jquery and jquery/jquery-storageapi
Step 2: So now you can get cookie information using
Step 3: window.localStorage is also supported to store the information at the local storage
These all are different approaches to store information.
Hence, with the help of the above code, all are able to. In case you face any difficulty, let me know by mentioning it in the comment section below. Share the article further and stay updated.
You may also like to refer – Magento 2 Cookie Notice (Everything You Need to Know)