0

I have an observer which is triggered properly on customer logout. The observer's execute method looks like this:

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $this->masterfilterHelper->deleteMasterFilterCookie();
}

The function deleteMasterFilterCookie() looks like this:

public function deleteMasterFilterCookie(): void
{
    $this->cookieManager->setPublicCookie('masterfilter', '');
    $this->cookieManager->deleteCookie('masterfilter');
}

The function is deleteMasterFilterCookie() is called properly, but the cookie is still available afterwards. When I call this function in other observer, everything works as expected.

UPDATE: events.xml

The delete-function is called in reset-masterfilter-homepage and there's no problem.
The reset-masterfilter-logout oberserver is also called properly but the cookie deletion has a different behaviour here.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="controller_action_predispatch">
        <observer name="reset-masterfilter-homepage" instance="Vendor\Module\Observer\MasterfilterHomepage" />
    </event>
    <event name="customer_logout">
        <observer name="reset-masterfilter-logout" instance="Vendor\Module\Observer\MasterfilterLogout" />
    </event>
</config>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.