Previous
Items 1 to 10 of 11

Today, we will explain you how to manage cookies in JavaScript using the default Mage.Cookie class that comes with Magento.

First, to create a cookie, we are going to use the set method. This function takes three parameters:

  • the first one is the cookie key
  • the second is the value of the cookie
  • finally, the last one is the expiry date

Below, you will find an example:

// Create a 60 days expiry date
var expiryDate = new Date();
expiryDate.setDate(expDate.getDate() + 60);
// Call the set method
Mage.Cookies.set('mycookie', 'yum', expiryDate);

Now that your cookie is set you will have to retrieve it. To do so, the get method takes the cookie key as a parameter.

Mage.Cookies.get("mycookie")

Finally, to erase the cookie, you have to use the set method again and you will delete the cookie by resetting the value and the expiry date to an earlier date.

var eraseDate = new Date();
eraseDate.setTime(eraseDate.getTime()+(-1*24*60*60*1000));
Mage.Cookies.set('mycookie', "", eraseDate);
0 Comments | Posted in Magento JavaScript By Raphaël Petrini
We have a release new versions of the following modules: - Abandoned Carts Notification - AJAX Login Popup Find the release notes in the articleRead More
0 Comments | Posted in Magento By Raphaël Petrini
In this article, we will describe how to add mass actions items to Magento grids using event observers.Read More
0 Comments | Posted in Magento PHP By Raphaël Petrini
We've got two big news for you.Read More
0 Comments | Posted in Magento By Raphaël Petrini
Over the last week, we have released three new Magento extensions. Come check them outRead More
0 Comments | Posted in Magento By Raphaël Petrini
Holidays are over, we are back with a new module, visiting cards and more infos!Read More
0 Comments | Posted in Magento By Raphaël Petrini
A quick tutorial on how to fix / update your Magento modules before the patch SUPEE-6788 release.Read More
0 Comments | Posted in Magento PHP By Raphaël Petrini

New Magento modules and updates

This month we have released two new modules as well as updated several existing extensions, check it out!Read More
0 Comments | Posted in Magento PHP By Raphaël Petrini
Digital Pianism starts a new year with some exciting announcements.Read More
0 Comments | Posted in Magento By Raphaël Petrini
Starting a new type of articles, where we explain and compare development processes between Magento 1 and Magento 2.Read More
0 Comments | Posted in Magento PHP By Raphaël Petrini
Items 1 to 10 of 11
Next