in reply to
I cordially suggest that you are dealing with an edge-case ... and the moment that you said that different browsers do it differently, the pragmatic verdict was coffin-nailed down. You simply need to be sure that the cookie names are unique. Instead of viewing the present implementation (which you observe is repeated in several places) as being either a bug or a limitation ... treat it as It Works That Way.™ You’ve got a program to write, and these aren’t the ’droids you’re looking for ...
As we all know, there will be dozens of This Sucks! and This Is Wrong! and This Is Stupid! ... every release of Internet Explorer provides us with a couple more outhouses full of that. So you’ll never run out of nodding heads here. And yet, somehow, despite all of this, we have programs to write.