well, like I said, that code would help me troubleshoot the problem, not fix it.
So if it is writing 6 to the screen, that means captcha is not validating.
the first place to start is to test your servers session management.
See the following post for a script you can use for testing session management on the server:
showpost.php?p=23826&postcount=2