> Setting a cookie for the www subdomain ensures that it’s only available for that subdomain and not globally across all subdomains.
No, www is not more secure because of cookies. As you said, it depends on how cookies are set, which is up to the host, as this is defined in the HTTP headers coming from the server. It's possible to access a cookie from "www.example.com" on "example.com" or "sub.example.com" if it's configured like that on the backend. Also the browser needs to comply. (Protip: most browsers do)
Ok but to my knowledge it is impossible to set a cookie on example.com and make it inaccessible to subdomain.example.com.
Try document.cookie = 'a=b' in a browser console on non-www domain and then do document.cookie on the www variant.
You'll see it not set. (The cookie will only be accessible on subdomains if you include the domain explicitly, like document.cookie = 'a=b;domain=toplevel.domain')
Cloudflare also puts cookies on the root domain.
I definitely agree though.