I've got a captcha command that sets the value of a Session and then refreshes the page if the captcha code isn't correct.
In verification section of the page:
$_SESSION['refresh']=1;
echo '<META HTTP-EQUIV="Refresh" Content="0"; URL="contact-test.php">';
When the page loads it runs a bit of php script to see if there is a value set for a session variable, if there is it then echos a javascript function for an alert box, which called in the in the body via an onLoad command.
At the very beginning of the code:
session_start();
if (isset($_SESSION['refresh'])) {
echo '<script type="text/javascript">
function loadalert ()
{alert("Incorrect security code, please try again.")}
</script>';}
Near as I can tell when the page refreshes the sessions value is lost, I suspect the session_start() command is clearing all previous sessions. I've tried a test echo sending out some text and the value of the session, both before the loop and in the loop; only the one before the loop gets echoed without a session value at refresh.