在Magento 2自定义模块中,我使用事件观察器设置了一个cookie,但是当启用站点缓存时它不起作用,请参见下面的代码
$publicCookieMetadata = $this->_cookieMetadataFactory->createPublicCookieMetadata()
->setDuration(2592000)
->setPath($this->_sessionManager->getCookiePath())
->setDomain($this->_sessionManager->getCookieDomain())
->setHttpOnly(false);
$cookie_name = 'cookie'.$key;
$this->_cookieManager->setPublicCookie($cookie_name,
$key,
$publicCookieMetadata
);
请为我提供解决方案
谢谢