I'm using

<event name="controller_action_predispatch">

This event not working when I refresh category page second time .

If anyone knows please explain me.

public function saveVisitorData()
        $currentUrl = $this->_urlInterface->getCurrentUrl();       
        $s = $this->sValues();      
 public function getCookieValue($val)
        $value = $this->_cookieManager->getCookie($val);
        return $value;
    public function setCookie($cn, $v1)
        $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration(static::COOKIE_LIFETIME)->setPath($this->sessionManager->getCookiePath())->setDomain($this->sessionManager->getCookieDomain());        
        $this->_cookieManager->setPublicCookie($cn, $v1, $metadata);


public function sValues()
        $s = array();

        $s[1] = $this->_request->getParam('s1');
        $s[2] = $this->_request->getParam('s2');
        if ($s[1]) {
            $this->setCookie(self::COOKIE_s1, $s[1]);
        } else {
            $s[1] = $this->getCookieValue(self::COOKIE_s1);
        if ($s[2]) {
            $this->setCookie(self::COOKIE_s2, $s[2]);
        } else {
            $s[2] = $this->getCookieValue(self::COOKIE_s2);
        return $s;


public function execute(Observer $observer)
       $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getFullActionName();
        if($curModule != 'customer_section_load'){
            echo 'In Observer';

  • can you please provide code what you are trying – Murtuza Zabuawala Dec 13 '17 at 8:17
  • updated my post@ Murtuza Zabuawala – Mano M Dec 13 '17 at 8:33

controller_action_predispatch event will not be called when FPC is turned ON. You have to use the event controller_front_send_response_before which will be called irrespective of the FPC running status.


in this case you can use following event

 <event name="controller_action_predispatch_customer_section_load" >

No need to check that condition

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.