Reputation: 450
I'm using an observer and this hook controller_action_postdispatch_customer_account_logout
on customer logout I wish for all set cookies to be deleted, but for some reason they continue to be present after customer logout, I'm certain the code is correct? any ideas?
public function deleteCookies(){
$cookies = Mage::getModel('core/cookie')->get();
foreach($cookies as $cookie) {
$name = Mage::getModel('core/cookie')->get($cookie);
$path = Mage::getModel('core/cookie')->getPath($cookie);
$lifetime = Mage::getModel('core/cookie')->getLifetime($cookie);
Mage::getModel('core/cookie')->delete($name, $path, $lifetime);
}
}
Upvotes: 0
Views: 2706
Reputation: 1116
the third parameter of the delete
function is not the lifetime of the cookie.
public function delete($name, $path = null, $domain = null, $secure = null, $httponly = null)
try this:
public function deleteCookies(){
$cookies = Mage::getSingleton('core/cookie')->get();
foreach($cookies as $cookieName) {
Mage::getSingleton('core/cookie')->delete($cookieName);
}
}
hope that helps
Upvotes: 2