in reply to Header data from arbitrary calls

AFAIK cookies must be set in the header, which is why I suggested adding it to the start of the HTML, unless you dynamically generate some javascript to set the cookie inline. I've used this strategy before and you have to be careful due to different browsers supporting different flavours of javascript.