Your problem is definitively based to the <img>
-tag you're using. No JavaScript Code will be executed in an image.
The reason why it works if you do it by PHP is because the server is pre-processing your code at the time of requesting the file. Although this probably wont show you anything because you did not provide any valid image header.
If you would use the <iframe>
-tag everything would work because the client can read and execute your JS-Code:
<iframe src='http://www.siteB.co.uk/cookie.php'></iframe>
But if you try to set the cookie by the <img>
-tag you need to do it with a server-side
language like PHP in this example.
Agencies like Doubleclick working with iframe, javascript snippets you sould insert into your page or|and a server-side solution.
Hope this helps.