我正在使用观察者和这个钩子controller_action_postdispatch_customer_account_logout
关于客户注销我希望删除所有设置的cookie,但由于某些原因,在客户注销后它们仍然存在,我确定代码是正确的吗?任何想法?
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);
}
}
答案 0 :(得分:1)
delete
函数的第三个参数不是cookie的生命周期。
public function delete($name, $path = null, $domain = null, $secure = null, $httponly = null)
试试这个:
public function deleteCookies(){
$cookies = Mage::getSingleton('core/cookie')->get();
foreach($cookies as $cookieName) {
Mage::getSingleton('core/cookie')->delete($cookieName);
}
}
希望有所帮助