100 days on Magento StackExchange
4/20/2016 12:39 PM
I've challenged myself to spend 100 days on Magento StackExchange, here's what happened.Read More
Start of a new year with exciting news
1/8/2016 11:20 AM
Digital Pianism starts a new year with some exciting announcements.Read More
New Magento modules and updates
11/26/2015 9:03 PM
This month we have released two new modules as well as updated several existing extensions, check it out!Read More
How to update your modules before the Magento patch SUPEE-6788
10/22/2015 6:46 PM
A quick tutorial on how to fix / update your Magento modules before the patch SUPEE-6788 release.Read More
New Magento module and visiting cards
10/10/2015 2:54 PM
Holidays are over, we are back with a new module, visiting cards and more infos!Read More
Three new Magento modules available via our online store
8/12/2015 1:37 PM
Over the last week, we have released three new Magento extensions. Come check them outRead More
Magento certification and new free module available now
8/6/2015 5:36 PM
We've got two big news for you.Read More
How to add mass action items to a Magento grid using event observers
7/28/2015 2:51 PM
In this article, we will describe how to add mass actions items to Magento grids using event observers.Read More
We have a release new versions of the following modules:
- Abandoned Carts Notification
- AJAX Login Popup
Find the release notes in the articleRead More
How to manage cookies with JavaScript using Mage.Cookies in Magento
11/21/2013 1:24 PM
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);