Skip to content

Commit

Permalink
Merge pull request #30 from bsdnomad/master
Browse files Browse the repository at this point in the history
Store switcher fix
  • Loading branch information
HirokazuNishi authored Jun 2, 2021
2 parents 1ce709e + 7d5a4a4 commit 2dff524
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Plugin/SwitchSameSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ public function beforeSetPublicCookie(
$agent = $this->header->getHttpUserAgent();
$sameSite = $this->validator->shouldSendSameSiteNone($agent);
if ($sameSite === false) {
$metadata->setSameSite('None');
$metadata
->setSecure(true)
->setSameSite('None');
} else {
$config = $this->scopeConfig->getValue(self::CONFIG_PATH, ScopeInterface::SCOPE_STORE);

// Convert to lowercase since sometimes it comes as lower-cased string
if(strtolower($config) === 'none')
{
$metadata->setSecure(true);
}
$metadata->setSameSite($config);
}
}
Expand Down
2 changes: 1 addition & 1 deletion etc/frontend/di.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\Stdlib\Cookie\PhpCookieManager">
<type name="Magento\Framework\Stdlib\CookieManagerInterface">
<plugin name="switch_samesite"
type="Veriteworks\CookieFix\Plugin\SwitchSameSite"
sortOrder="10"/>
Expand Down
2 changes: 1 addition & 1 deletion etc/webapi_rest/di.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\Stdlib\Cookie\PhpCookieManager">
<type name="Magento\Framework\Stdlib\CookieManagerInterface">
<plugin name="switch_samesite"
type="Veriteworks\CookieFix\Plugin\SwitchSameSite"
sortOrder="10"/>
Expand Down

0 comments on commit 2dff524

Please sign in to comment.