I've followed this question but set
method mentioned there is outdated (Reference: Magento\Framework\App\PageCache\FormKey::set()).
So, a cookie is created like this:
public function set($value, PublicCookieMetadata $metadata)
{
$this->cookieManager->setPublicCookie(
self::COOKIE_NAME,
$value,
$metadata
);
}
Where $metadata
should be an instance of PublicCookieMetadata
.
In one of the plugin I'm using $this->customerCountry->set('India', 10);
I know I'm doing wrong here. Instead of passing 10
as the second parameter I need to pass instance of PublicCookieMetadata
. How I can do that? I've tried $this->customerCountry->set('India', PublicCookieMetadata $metadat =null);
which seems to be wrong. How I can creat and set duration of the cookie?