Hmm.....I was just thinking to myself that the way to do this would be to use a meta refresh tag after you have done everything you need in window B, which could send the variables back to window A. Then I realised that it is not possible to use 'target' values in a meta tag.
The only way I can think of doing this is to use a link that you have to click in window B - I cannot think of an automatic way.
// all of the stuff you need to happen in window B goes above here
echo "<a href='javascript:opener.location.href=url.php?variable=" . $variable . ";'>Click Here</a>";
// this will target the window that opened it, and you can pass variables back in the url, as I have shown
That is the best way I can think of doing it anyway. I am not sure if the javascript would work in a <meta> tag, but you could try it if you want.