Skip to content

Commit 79e075c

Browse files
committed
ACP2E-1445: Customer data in Local Storage not reset when session file lost
- Fixed the session clear issue.
1 parent fd42a67 commit 79e075c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ define([
5353
storage.removeAll();
5454
}
5555

56-
if (isLoggedIn === 0) {
56+
if (!$.localStorage.isSet('mage-customer-login')) {
57+
$.localStorage.set('mage-customer-login', isLoggedIn);
58+
}
59+
if ($.localStorage.get('mage-customer-login') !== isLoggedIn) {
60+
$.localStorage.set('mage-customer-login', isLoggedIn);
5761
storage.removeAll();
5862
}
5963

app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\PageCache\Model\App\FrontController;
77

88
use Magento\Framework\App\Response\Http as ResponseHttp;
9+
use Magento\Customer\Model\Session;
910

1011
/**
1112
* Plugin for processing builtin cache
@@ -32,24 +33,40 @@ class BuiltinPlugin
3233
*/
3334
protected $state;
3435

36+
/**
37+
* @var ResponseHttp
38+
*/
39+
protected $responseHttp;
40+
41+
/**
42+
* @var Session
43+
*/
44+
private $session;
45+
3546
/**
3647
* Constructor
3748
*
3849
* @param \Magento\PageCache\Model\Config $config
3950
* @param \Magento\Framework\App\PageCache\Version $version
4051
* @param \Magento\Framework\App\PageCache\Kernel $kernel
4152
* @param \Magento\Framework\App\State $state
53+
* @param ResponseHttp $responseHttp
54+
* @param Session $session
4255
*/
4356
public function __construct(
4457
\Magento\PageCache\Model\Config $config,
4558
\Magento\Framework\App\PageCache\Version $version,
4659
\Magento\Framework\App\PageCache\Kernel $kernel,
47-
\Magento\Framework\App\State $state
60+
\Magento\Framework\App\State $state,
61+
ResponseHttp $responseHttp,
62+
Session $session
4863
) {
4964
$this->config = $config;
5065
$this->version = $version;
5166
$this->kernel = $kernel;
5267
$this->state = $state;
68+
$this->responseHttp = $responseHttp;
69+
$this->session = $session;
5370
}
5471

5572
/**
@@ -66,6 +83,9 @@ public function aroundDispatch(
6683
\Closure $proceed,
6784
\Magento\Framework\App\RequestInterface $request
6885
) {
86+
if (!$this->session->getCustomerId()) {
87+
$this->responseHttp->sendVary();
88+
}
6989
$this->version->process();
7090
if (!$this->config->isEnabled() || $this->config->getType() !== \Magento\PageCache\Model\Config::BUILT_IN) {
7191
return $proceed($request);

0 commit comments

Comments
 (0)