Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UnsetCookie.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class UnsetCookie extends Index
12 {
18  public function execute()
19  {
20  if ($this->sessionHelper->isPersistent()) {
21  $this->cleanup();
22  }
24  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
25  $resultRedirect->setPath('customer/account/login');
26  return $resultRedirect;
27  }
28 
34  protected function cleanup()
35  {
36  $this->_eventManager->dispatch('persistent_session_expired');
37  $this->customerSession->setCustomerId(null)->setCustomerGroupId(null);
38  if ($this->clearCheckoutSession) {
39  $this->checkoutSession->clearStorage();
40  }
41  $this->sessionHelper->getSession()->removePersistentCookie();
42  return $this;
43  }
44 }