Skip to content

Commit 4b58b0e

Browse files
author
Oleksandr Karpenko
committed
MAGETWO-52593: Minicart does not clean when customer session is over
1 parent 7e4c607 commit 4b58b0e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

app/code/Magento/Customer/Controller/Account/CreatePost.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ class CreatePost extends \Magento\Customer\Controller\AbstractAccount
8282
*/
8383
private $accountRedirect;
8484

85+
/**
86+
* @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
87+
*/
88+
private $cookieMetadataFactory;
89+
90+
/**
91+
* @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
92+
*/
93+
private $cookieMetadataManager;
94+
8595
/**
8696
* @param Context $context
8797
* @param Session $customerSession
@@ -144,6 +154,38 @@ public function __construct(
144154
parent::__construct($context);
145155
}
146156

157+
/**
158+
* Retrieve cookie manager
159+
*
160+
* @deprecated
161+
* @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
162+
*/
163+
private function getCookieManager()
164+
{
165+
if (!$this->cookieMetadataManager) {
166+
$this->cookieMetadataManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
167+
\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class
168+
);
169+
}
170+
return $this->cookieMetadataManager;
171+
}
172+
173+
/**
174+
* Retrieve cookie metadata factory
175+
*
176+
* @deprecated
177+
* @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
178+
*/
179+
private function getCookieMetadataFactory()
180+
{
181+
if (!$this->cookieMetadataFactory) {
182+
$this->cookieMetadataFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
183+
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::class
184+
);
185+
}
186+
return $this->cookieMetadataFactory;
187+
}
188+
147189
/**
148190
* Add address to customer during create account
149191
*
@@ -267,6 +309,12 @@ public function execute()
267309
}
268310
$resultRedirect = $this->accountRedirect->getRedirect();
269311
}
312+
if ($this->getCookieManager()->getCookie('mage-cache-sessid')) {
313+
$metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
314+
$metadata->setPath('/');
315+
$this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);
316+
}
317+
270318
return $resultRedirect;
271319
} catch (StateException $e) {
272320
$url = $this->urlModel->getUrl('customer/account/forgotpassword');

0 commit comments

Comments
 (0)