I need to unset the error message session in magento for below code.
Mage::getSingleton('core/session')->addError($message);
Can any one help me?
Unset sessions in Magento 2 In case you want to unset those sessions, let do as the following: $block->getCatalogSession()->unsMyName(); $block->getCheckoutSession()->unsTestData(); $block->getCustomerSession()->unsTestHello();
Magento2 provides five types of sessions: Magento\Backend\Model\Session– This session is used for Magento backend. Magento\Catalog\Model\Session– Catalog session is used for the frontend for product filters. Magento\Checkout\Model\Session– Checkout session is used to store checkout related information.
You should be able to use the following code, though it will return all messages (it will not echo them), it will clear them:
Mage::getSingleton('core/session')->getMessages(true); // The true is for clearing them after loading them
I hope this answers your question. ^_^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With