php - Loop all Magento Cookies & Delete -
i have magento site location ip plugin. uses cookies heavily. because of this, need clear cookies magento sets. have believe correct code it's not working:
$cookies = mage::getmodel('core/cookie')->get(); foreach($cookies $cookie) { mage::getmodel('core/cookie')->delete($cookie->name, $cookie->path); }
some cookies set on path '/' , on /another'. clear avoid confusion.
any ideas on how can this? thanks!
you getting error because $cookie->name , $cookie->path not objects. loop work try this.
$names = mage::getmodel('core/cookie')->get(); //this returns array of cookies foreach($names $name) { //loop through array $cookie = mage::getmodel('core/cookie')->get($name); //get cookie object each cookie $path = $cookie->getpath(); //get path cookie mage::getmodel('core/cookie')->delete($name, $path); //delete cookie }
Comments
Post a Comment