Skip to content

Commit 0eaa3da

Browse files
MAGETWO-72254: Backport PR-9713 for Magento 2.1 - stringify cookie value to fix #5596 #10749
2 parents 8390ef4 + f200327 commit 0eaa3da

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

app/code/Magento/Cookie/Helper/Cookie.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,22 @@ public function __construct(
6969
public function isUserNotAllowSaveCookie()
7070
{
7171
$acceptedSaveCookiesWebsites = $this->_getAcceptedSaveCookiesWebsites();
72+
return $this->isCookieRestrictionModeEnabled() &&
73+
empty($acceptedSaveCookiesWebsites[$this->_website->getId()]);
74+
}
75+
76+
/**
77+
* Check if cookie restriction mode is enabled for this store
78+
*
79+
* @return bool
80+
*/
81+
public function isCookieRestrictionModeEnabled()
82+
{
7283
return $this->scopeConfig->getValue(
7384
self::XML_PATH_COOKIE_RESTRICTION,
7485
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
7586
$this->_currentStore
76-
) && empty($acceptedSaveCookiesWebsites[$this->_website->getId()]);
87+
);
7788
}
7889

7990
/**

app/code/Magento/Cookie/view/frontend/templates/html/notices.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
?>
1010
<?php /** @var \Magento\Cookie\Block\Html\Notices $block */ ?>
11-
<?php if ($this->helper('Magento\Cookie\Helper\Cookie')->isUserNotAllowSaveCookie()): ?>
11+
<?php if ($this->helper('Magento\Cookie\Helper\Cookie')->isCookieRestrictionModeEnabled()): ?>
1212
<div class="message global cookie" id="notice-cookie-block" style="display: none">
1313
<div class="content">
1414
<p>

app/code/Magento/Cookie/view/frontend/web/js/notices.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ define([
2020
$(this.options.cookieAllowButtonSelector).on('click', $.proxy(function() {
2121
var cookieExpires = new Date(new Date().getTime() + this.options.cookieLifetime * 1000);
2222

23-
$.mage.cookies.set(this.options.cookieName, this.options.cookieValue, {expires: cookieExpires});
23+
$.mage.cookies.set(this.options.cookieName, JSON.stringify(this.options.cookieValue), {
24+
expires: cookieExpires
25+
});
26+
2427
if ($.mage.cookies.get(this.options.cookieName)) {
2528
window.location.reload();
2629
} else {

0 commit comments

Comments
 (0)