If I were you, I would try visiting this script of yours in a browser to make sure it doesn't have any syntax errors. If you made one little mistake then it's not going to work.
I'd also make a temporary mod to write your $POST data to a file to make sure that paypal is in fact calling this page:
file_put_contents('log_file.txt', print_r($_POST, TRUE));
Once you are sure that Paypal is really sending data to your page, you'll have a better chance of debugging your script.
If it's not working at that point, then it could be because that script snippet opens a raw socket connection back to paypal using [man]fsockopen[/man]. I think you need to have the sockets extension installed for that.
Also, read the docs on [man]session_register[/man]. I don't it does what you think it does.