I am guessing you probably found a solution by now, but…
I was trying to do the same thing. It wouldn’t work. The work around I used was creating a function before the get_header() tag. While the content in the header wouldn’t recognize variables set previously, it would make a call to a function set previously.
So, in your case you could create a function like:
<?php
function myVariable(){
return = “something”;
}
?>
Then when you want to use that “variable” in the header, sidebar or footer, you could do something like:
<?php
if(myVariable() == “something”){
//do stuff
}
?>
Not sure if that will help for your situation, but it works for what I needed.