How to Delete Cookie Values

cookiesession

In my controller function I'm setting cookie like

$cookie = Mage::getSingleton('core/cookie');
$cookie->set('frontAttributeLabel',$frontAttributeLabel ,time()+86400,'/');

In observer I'm retriving it's value and using it

$cookie = Mage::getSingleton('core/cookie'); 
$frontAttributeLabel = $cookie->get('frontAttributeLabel');

In the observer function it's working fine. After it's usage I'm deleting it using

$cookie->delete('frontAttributeLabel');

Once I'm done with the use of this observer (catalog_product_load_after) function, next time I'm visiting the page again I see it's previous value is set.
I'm using wrong function to delete cookie? or I need to pass more parameters in delete function?

Best Answer

try passing the path (/) as second argument in delete. And try using a set with a time in the past to delete if that doesn't work.

$cookie->set('frontAttributeLabel',$frontAttributeLabel ,time()-100,'/');

If both don't work it's not a deleting issue but something else

Related Topic