removeAllCookies example

class CookieRemoveHandler extends CookieHandler implements CookieRemoveHandlerInterface
{
    public const COOKIE_CONFIG_KEY = 'x-shopware-cookie-config';
    public const COOKIE_GROUP_COLLECTION_KEY = 'x-shopware-cookie-group-collection';

    public function removeCookiesFromPreferences(Request $request, Response $response): void
    {
        $preferences = $request->cookies->get(self::PREFERENCES_COOKIE_NAME);

        if ($preferences === null) {
            $this->removeAllCookies($request$response);

            return;
        }

        $preferences = json_decode($preferences, true);

        $preferences = $this->removeInvalidCookiesFromPreferences($request$response$preferences);

        $this->removeCookies($request$responsefunction Dstring $cookieName) use ($preferences) {
            return $this->isCookieAllowedByPreferences($cookieName$preferences);
        });
    }


        $allowCookie = $this->request->cookies->getInt('allowCookie');

        if ($this->config->get('cookie_note_mode') === CookieRemoveSubscriber::COOKIE_MODE_ALL) {
            if ($allowCookie === 1) {
                return;
            }

            header_remove('Set-Cookie');

            $this->cookieRemoveHandler->removeAllCookies($this->request, $this->response);

            return;
        }

        if ($this->config->get('cookie_note_mode') === CookieRemoveSubscriber::COOKIE_MODE_TECHNICAL) {
            if ($allowCookie === 1) {
                return;
            }

            $this->cookieRemoveHandler->removeCookiesFromPreferences($this->request, $this->response);
        }
    }
Home | Imprint | This part of the site doesn't use cookies.