Mage::getModel('core/cookie')->set('visitor_id', $visitorId, $this->_getExpiryTime(), '/');
How to convert this code into magento2?
I have trying this:
$this->_cookieManager->setCookie('visitor_id', $visitorId, $this->getExpiryTime(), '/');
But its shows error.
This is my fun()
:
public function generateVisitorId()
{
$visitorId = $this->_checkoutSession->get('visitor_id');
if (!$visitorId) {
$visitorId = uniqid();
$this->_cookieManager->setCookie('visitor_id', $visitorId, $this->getExpiryTime(), '/');
}
return $visitorId;
}