session = $customerSession; parent::__construct($context); } /** * Retrieve cookie manager * * @deprecated 100.1.0 * @return PhpCookieManager */ private function getCookieManager() { if (!$this->cookieMetadataManager) { $this->cookieMetadataManager = ObjectManager::getInstance()->get(PhpCookieManager::class); } return $this->cookieMetadataManager; } /** * Retrieve cookie metadata factory * * @deprecated 100.1.0 * @return CookieMetadataFactory */ private function getCookieMetadataFactory() { if (!$this->cookieMetadataFactory) { $this->cookieMetadataFactory = ObjectManager::getInstance()->get(CookieMetadataFactory::class); } return $this->cookieMetadataFactory; } /** * Customer logout action * * @return \Magento\Framework\Controller\Result\Redirect */ public function execute() { $lastCustomerId = $this->session->getId(); $this->session->logout()->setBeforeAuthUrl($this->_redirect->getRefererUrl()) ->setLastCustomerId($lastCustomerId); if ($this->getCookieManager()->getCookie('mage-cache-sessid')) { $metadata = $this->getCookieMetadataFactory()->createCookieMetadata(); $metadata->setPath('/'); $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata); } /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('*/*/logoutSuccess'); return $resultRedirect; } }