@@ -49,6 +49,16 @@ class Confirm extends \Magento\Customer\Controller\AbstractAccount
49
49
*/
50
50
protected $ session ;
51
51
52
+ /**
53
+ * @var \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
54
+ */
55
+ private $ cookieMetadataFactory ;
56
+
57
+ /**
58
+ * @var \Magento\Framework\Stdlib\Cookie\PhpCookieManager
59
+ */
60
+ private $ cookieMetadataManager ;
61
+
52
62
/**
53
63
* @param Context $context
54
64
* @param Session $customerSession
@@ -79,6 +89,38 @@ public function __construct(
79
89
parent ::__construct ($ context );
80
90
}
81
91
92
+ /**
93
+ * Retrieve cookie manager
94
+ *
95
+ * @deprecated
96
+ * @return \Magento\Framework\Stdlib\Cookie\PhpCookieManager
97
+ */
98
+ private function getCookieManager ()
99
+ {
100
+ if (!$ this ->cookieMetadataManager ) {
101
+ $ this ->cookieMetadataManager = \Magento \Framework \App \ObjectManager::getInstance ()->get (
102
+ \Magento \Framework \Stdlib \Cookie \PhpCookieManager::class
103
+ );
104
+ }
105
+ return $ this ->cookieMetadataManager ;
106
+ }
107
+
108
+ /**
109
+ * Retrieve cookie metadata factory
110
+ *
111
+ * @deprecated
112
+ * @return \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory
113
+ */
114
+ private function getCookieMetadataFactory ()
115
+ {
116
+ if (!$ this ->cookieMetadataFactory ) {
117
+ $ this ->cookieMetadataFactory = \Magento \Framework \App \ObjectManager::getInstance ()->get (
118
+ \Magento \Framework \Stdlib \Cookie \CookieMetadataFactory::class
119
+ );
120
+ }
121
+ return $ this ->cookieMetadataFactory ;
122
+ }
123
+
82
124
/**
83
125
* Confirm customer account by id and confirmation key
84
126
*
@@ -104,7 +146,11 @@ public function execute()
104
146
$ customerEmail = $ this ->customerRepository ->getById ($ customerId )->getEmail ();
105
147
$ customer = $ this ->customerAccountManagement ->activate ($ customerEmail , $ key );
106
148
$ this ->session ->setCustomerDataAsLoggedIn ($ customer );
107
-
149
+ if ($ this ->getCookieManager ()->getCookie ('mage-cache-sessid ' )) {
150
+ $ metadata = $ this ->getCookieMetadataFactory ()->createCookieMetadata ();
151
+ $ metadata ->setPath ('/ ' );
152
+ $ this ->getCookieManager ()->deleteCookie ('mage-cache-sessid ' , $ metadata );
153
+ }
108
154
$ this ->messageManager ->addSuccess ($ this ->getSuccessMessage ());
109
155
$ resultRedirect ->setUrl ($ this ->getSuccessRedirect ());
110
156
return $ resultRedirect ;
0 commit comments