I want to set the cookie lifetime
in my phtml file.
I am using the following code:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cookieManager = $objectManager->get('Magento\Framework\Stdlib\CookieManagerInterface');
$cookieMetadataFactory = \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::getInstance();
$cookie_lifetime = (90 * 60);//90 days
$cookie_metadata = $cookieMetadataFactory->createPublicCookieMetadata()->setDuration($cookie_lifetime);
$cookieManager->setPublicCookie('cookie1', 'value', $cookie_metadata);
I get this error:
Call to undefined method Magento\Framework\Stdlib\Cookie\CookieMetadataFactory::getInstance()
So, is there no getInstance method? What can I use instead?