config = $config; $this->cookieManager = $cookieManager; $this->cookieMetadataFactory = $cookieMetadataFactory; } public function get(): ?string { $value = $this->cookieManager->getCookie($this->config->getMarketCookieName()); return $value !== null ? trim($value) : null; } public function set(string $market): void { $metadata = $this->cookieMetadataFactory->createPublicCookieMetadata([ CookieMetadata::KEY_DURATION => $this->config->getMarketCookieLifetime(), CookieMetadata::KEY_SAME_SITE => 'Lax', ]); $metadata->setPath('/'); $metadata->setHttpOnly(false); $this->cookieManager->setPublicCookie( $this->config->getMarketCookieName(), $market, $metadata ); if ($this->config->getMarketCookieName() !== self::STORE_COOKIE_NAME) { $storeMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata([ CookieMetadata::KEY_DURATION => 31536000, CookieMetadata::KEY_SAME_SITE => 'Lax', ]); $storeMetadata->setPath('/'); $storeMetadata->setHttpOnly(false); $this->cookieManager->setPublicCookie( self::STORE_COOKIE_NAME, $market, $storeMetadata ); } } }