headers->getCookies() as $cookie) { $sameSite = $cookie->getSameSite(); if($sameSite == Cookie::SAMESITE_NONE){ // check if we could use it or not if(CookieSameSitePolicy::isSameSiteNoneIncompatible()){ // replace the cookie with a compatible version ( unset sameSite value) // make a clone $compatibleCookie = Cookie::create ( $cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly(), $cookie->isRaw(), null ); // and overwrite it $response->headers->setCookie($compatibleCookie); } } } return $response; } }