I was trying to add set cookie to this, which works (set cookie to expire 1 year from set date), but resets the cookie value each time. I want to check if someone has already entered their age and if so, direct them to the appropriate response page. i.e. - don't want a youth hitting back button and enter different age. I know this is easily circumvented anyways, but ESRB requires it for adult game trailers, etc. Here is what I have so far -
<?php
$allowed_age = 18;
$bdate = strtotime($_REQUEST['year'].'-'.$_REQUEST['month']."-".$_REQUEST['day']);
$age = (time()-$bdate)/31536000;
if($age >= $allowed_age) {
setcookie('legal', 'yes', time() + 31556926, '/', '.'.$_SERVER['SERVER_NAME']);
header('Location: http://192.168.1.73/adult.html');
exit;
}
else {
setcookie('legal', 'no', time() + 31556926, '/', '.'.$_SERVER['SERVER_NAME']);
header('Location: http://192.168.1.73/minor.html');
exit;
}
?>
Here is what the cookie looks like if I retrieve it -
for minor:
noArray ( [0379923826258bc7cbcfa89cd386917d] => e33f27206e07981d495d11f70581e790 [29e6895b11c34b79d161fe2a6f1702f0] => b7b4ff91eb8090ad2f85d6a2100d3c4e [legal] => no )
for adult:
yesArray ( [0379923826258bc7cbcfa89cd386917d] => e33f27206e07981d495d11f70581e790 [29e6895b11c34b79d161fe2a6f1702f0] => b7b4ff91eb8090ad2f85d6a2100d3c4e [legal] => yes )
Thanks in advance for any help!