My original point remains valid: setting a session variable to 1 or 0 is not a solution to the original question - it needs to be a random number. The link I provided discusses the use of a random number in more detail. The fact that I hadn't worked through the code that the page provides in detail won't prevent me from offering a link to it, if I believe it would be useful to the OP in understanding the problem.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity
." Me Myself & Irene
Validate your HTML