Cookies don't work correctly with Cloudflare

On my wordpress site, I use Cookie Notice plugin with Code Snippets, to deal with Google Analytics.

My PHP snippet looks like this:

add_action( 'init', 'set_monsterinsight_cookie_according_to_cookie_notice' );

function set_monsterinsight_cookie_according_to_cookie_notice() {
	if ( function_exists( 'cn_cookies_accepted' ) && function_exists('monsterinsights_get_ua'))
	{
		$cookie_name = 'ga-disable-'.monsterinsights_get_ua();
		if (isset($_COOKIE[$cookie_name]))
		{
			if ($_COOKIE[$cookie_name] == "false")
			{
				return;
			}
		}
		if ( cn_cookies_accepted() ) {
			setCookie($cookie_name, 'false', 0, "/");
		}
		else{
			setCookie($cookie_name, 'true', 0, "/");
		}
	}
}

If I use Cloudflare Development Mode (bypassing cache), the cookies set up correctly.

If I dont use Development mode, the cookies look like they are cached. Google analytics cookies are set before I consent, and after I consent, the cookie_notice_accepted is set to true. Cookie ga-disable-XXXXX is never set.

My Cloudflare Page Rules:

I don’t understand what is going on, so any help is much appreciated.