/** * Delete frontend session cookie if customer session is expired * * @param SessionManager $sessionManager */ public function beforeStart(SessionManager $sessionManager) { if (!$this->cookieManager->getCookie($sessionManager->getName()) && $this->cookieManager->getCookie('mage-cache-sessid')) { $metadata = $this->cookieMetadataFactory->createCookieMetadata(); $metadata->setPath('/'); $this->cookieManager->deleteCookie('mage-cache-sessid', $metadata); } }
public function testDeleteCookieWithFailureToSendException() { self::$isSetCookieInvoked = false; $cookieMetadata = $this->objectManager->getObject('Magento\\Framework\\Stdlib\\Cookie\\CookieMetaData'); $this->scopeMock->expects($this->once())->method('getCookieMetadata')->with()->will($this->returnValue($cookieMetadata)); try { $this->cookieManager->deleteCookie(self::EXCEPTION_COOKIE_NAME, $cookieMetadata); $this->fail('Expected exception not thrown.'); } catch (FailureToSendException $fse) { $this->assertTrue(self::$isSetCookieInvoked); $this->assertSame('Unable to delete the cookie with cookieName = exception_cookie_name', $fse->getMessage()); } }