Skip to content

Magento: Set, Get & Delete Cookies

this is example how to manage cookies in Magento:

 

Set Cookies:

$name_c = ‘cookies_name’;

$val_c = ‘cookies_value’;

$expired = 31556926; /* 1 year */

$path = ‘/’;

 

$cookie = Mage::getSingleton(‘core/cookie’);
$cookie->set($name_c, $val_c ,$expired,$path);

Get Cookies:

$name_c = ‘cookies_name’;

$cookie_value = Mage::getModel(‘core/cookie’)->get($name_c);

Delete Cookies:

$name_c = ‘cookies_name’;

Mage::getModel(‘core/cookie’)->delete($name_c).

So easy right? haha 😀

Share