_persistentData = $persistentData; $this->_persistentSession = $persistentSession; $this->_customerSession = $customerSession; $this->_sessionFactory = $sessionFactory; } /** * Renew persistent cookie * * @param Observer $observer * @return void */ public function execute(Observer $observer) { if (!$this->_persistentData->canProcess($observer) || !$this->_persistentData->isEnabled() || !$this->_persistentSession->isPersistent() ) { return; } /** @var $request \Magento\Framework\App\RequestInterface */ $request = $observer->getEvent()->getRequest(); if ($this->_customerSession->isLoggedIn() || $request->getFullActionName() == 'customer_account_logout') { $this->_sessionFactory->create() ->renewPersistentCookie( $this->_persistentData->getLifeTime(), $this->_customerSession->getCookiePath() ); } } }