As a part of my functionality, using below I'm dispatching a conditional error message.

<event name="controller_action_predispatch">
    <observer name="controller_post_dispatch_sessionTimeout_message" instance="AAMC\Customer\Observer\SessionTimeoutMessage" />

public function execute(\Magento\Framework\Event\Observer $observer)
        if(!$this->customerLoggedIn() && $this->_cookieManager->getCookie(CustomerHelper::LOGGED_IN_COOKIE)){
            $this->_messageManager->addErrorMessage('Session time out. Please login to continue');

Messages are displaying only in uncacheable pages like customer, checkout but it failed to display messages in cacheable pages like home, product listing, product detail etc.

I've verified the same by disabling cache. Any help will be appreciated !


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.