2

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?

  • 1
    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. If both don't work it's not a deleting issue but something else – Sander Mangel Sep 28 '15 at 8:47
  • @SanderMangel: Thanks. it worked :). Please put it in answer section and I'll accept it. – amitshree Sep 28 '15 at 8:51
  • Added it as answer. Glad I could help – Sander Mangel Sep 28 '15 at 8:56
2

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.