Skip to content

cookie

Auto Added by WPeMatico

Set cookie not working with varnish

I’ve created the following observer method that sets a cookie: if ($this->_cookieManager->getCookie(self::COOKIE_NAME)) { $this->_cookieManager->deleteCookie( self::COOKIE_NAME, $this->_cookieMetadataFactory ->createCookieMetadata() ->setPath(‘/’) ->setDomain(null) ); } $metadata = $this->_cookieMetadataFactory ->createPublicCookieMetadata() ->setDuration(self::COOKIE_DURATION) ->setPath(‘/’) ->setDomain(null); $this->_cookieManager->setPublicCookie( self::COOKIE_NAME, $mediumValue, $metadata ); It observes the event controller_action_predispatch to run… Read More »Set cookie not working with varnish

Magento 2 Cookie not able to clear from JS

I am unable to clear the cookie on my Magento site. I am setting the cookie as below which is done successfully use MagentoFrameworkStdlibCookieCookieMetadataFactory; use MagentoFrameworkStdlibCookieManagerInterface; $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata(); $publicCookieMetadata->setPath(‘/’); $publicCookieMetadata->setHttpOnly(false); $publicCookieMetadata->setSameSite(‘Strict’); $this->cookieManager->setPublicCookie( self::COOKIE_NAME, 1, $publicCookieMetadata ); After that, I… Read More »Magento 2 Cookie not able to clear from JS