Magento Cookies: Set, Get and Delete
Create, read, update and delete Magento cookies with the core/cookie model — code examples for the frontend and admin areas.
Magento Cookies
Magento Cookies : one of key feature of magento that helps to manage frontend and admin section
Here is code to create , edit or delete cookies
<?php
Mage::getModel('core/cookie')->set($name, $value, $period, $path, $domain, $secure, $httponly);
/**
* get cookie with a specific name
* $name = name of the cookie
*/
Mage::getModel('core/cookie')->get($name);
/**
* get all cookies as an array
*/
Mage::getModel('core/cookie')->get();
/**
* delete/remove cookie
* $name is mandatory; other parameters are optional and cen be set as null
*/
Mage::getModel('core/cookie')->delete($name, $path, $domain, $secure, $httponly);
?>
Still on Magento 1? This tutorial is for Magento 1.x, which reached end of life in June 2020 and no longer receives security patches. Our team migrates Magento 1 stores to Magento 2, Mage-OS or Adobe Commerce with your SEO and data intact — see our Magento development services.
Further reading: OpenMage, the community-maintained Magento 1 fork. Need a hand? Our Magento development team can help.
