cancel
Showing results for 
Search instead for 
Did you mean: 

how to fix error/success message not hide after refresh or redirect to another page ?

SOLVED

Re: how to fix error/success message not hide after refresh or redirect to another page ?


@yagnik_solanki1 wrote:

Magento Version : 2.3.0

 

Hello,

 

I want to remove error/success message after refresh or redirect to another website page.

 

Please suggest me, how can i fix it ?

 

Thanks in advance.


I also got issue but upgradation is helpful for me. Try to upgrade it and it will resolve your website issue.

Re: how to fix error/success message not hide after refresh or redirect to another page ?

Hello @yagnik_solanki1 

After deleting a cookie record called "mage-messages", The old message won't be shown again.

I used the following code to remove it programmatically

...
private $_cookieManager;
...
public function __construct(    ...
    \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
) {
    ...
    $this->_cookieManager = $cookieManager;
}
...
private function _deleteMessage() {        
    $this->_cookieManager->deleteCookie('mage-messages');
}
...


I hope this solution will help you

Re: how to fix error/success message not hide after refresh or redirect to another page ?

Hello @yagnik_solanki1 

After deleting a cookie record called "mage-messages", The old message won't be shown again.

I used the following code to remove it programmatically

...
private $_cookieManager;
...
public function __construct(    ...
    \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
) {
    ...
    $this->_cookieManager = $cookieManager;
}
...
private function _deleteMessage() {        
    $this->_cookieManager->deleteCookie('mage-messages');
}
...


I hope this solution will help you

Re: how to fix error/success message not hide after refresh or redirect to another page ?

Hello @yagnik_solanki1  ,

After deleting a cookie record called "mage-messages", The old message won't be shown again.

I used the following code to remove it programmatically

...
private $_cookieManager;
...
public function __construct(    ...
    \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
) {
    ...
    $this->_cookieManager = $cookieManager;
}
...
private function _deleteMessage() {        
    $this->_cookieManager->deleteCookie('mage-messages');
}
...


I hope this solution will help you

Re: how to fix error/success message not hide after refresh or redirect to another page ?

Hello @yagnik_solanki1 ,
After deleting a cookie record called "mage-messages", The old message won't be shown again.

I used the following code to remove it programmatically : - 

...
private $_cookieManager;
...
public function __construct(    ...
    \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
) {
    ...
    $this->_cookieManager = $cookieManager;
}
...
private function _deleteMessage() {        
    $this->_cookieManager->deleteCookie('mage-messages');
}
...


I hope this solution will help you

Re: how to fix error/success message not hide after refresh or redirect to another page ?

Hello @yagnik_solanki1 ,

there is a cookie record called "mage-messages". After deleting it, the old message won't be shown again.

Re: how to fix error/success message not hide after refresh or redirect to another page ?

@syedkamranef82  Where to add this code, from where and when to call this function