I have
<?php ob_start(); ?>
<?php
$rng2 = random_string('alnum', 24);
setcookie("rng2", md5($rng2), time()+7200, '/');
?>
as my first 5 lines of my page. I do have <?php ob_end_flush(); ?>
at the end of my page.
I am also checking the value of the cookie after page reload with the lines
print_r($_COOKIE);
echo "<br /><br />".$_COOKIE['rng2']."/cookie[rng2]<br />";
echo $_POST['f']."/post[f]<br />";
echo md5($_POST['f'])."/md5(post[f])<br />";
if($_COOKIE['rng2'] != md5($_POST['f'])){
$err .= "There was an error submitting the form.<br />";
}
the cookie ['rng2'] does not show up in my print_r() and the variable $_COOKIE['rng2'] displays no space between the two "/"'s, the $_POST['f'] comes up correct.
I can't seem to get this to work. I can't find anything online about having it matter if the page the cookie is set on is an include but I figured I'd mention that it is.
Any insight would be helpful. Thank you.