A little PHP will do the trick. Add the following code to the top (after <?php) of the index.php page in the root.
if ($_COOKIE['of_age'] == "")
{
header("Location: <a href="http://your-site.com/verification.php">http://your-site.com/verification.php"</a>);
exit;
}
elseif ($_COOKIE['of_age'] == "no")
{
header("Location: <a href="http://your-site.com/verification-failed.php">http://your-site.com/verification-failed.php"</a>);
exit;
}
This will check for a cookie called “of_age” and see if it doesn’t exist or if it is set to no.
Then add a verification.php file in the root, with your form and this bit of php code at the top:
<?php
if (isset($_COOKIE['of_age']) == "")
{
if (isset($_POST['of_age']))
{
$v = $_POST['of_age'];
setcookie('of_age', $v, time() + (86400 * 7), '', '.your-site.com'); // 86400 = 1 day
if ($v == "yes")
{
header("Location: <a href="http://your-site.com">http://your-site.com"</a>);
exit;
}
if ($v == "no")
{
header("Location: <a href="http://your-site.com/verification-failed.php">http://your-site.com/verification-failed.php"</a>);
exit;
}
}
}
elseif (isset($_COOKIE['of_age']) == "yes")
{
header("Location: <a href="http://your-site.com">http://your-site.com"</a>);
exit;
}
elseif (isset($_COOKIE['of_age']) == "no")
{
header("Location: <a href="http://your-site.com/verification-failed.php">http://your-site.com/verification-failed.php"</a>);
exit;
}
?>
Form:
<form action="verification.php" method="post">
<h1>Are you over 21 years of age?</h1>
Yes <input type="radio" name="of_age" value="yes"/> No <input type="radio" name="of_age" value="no"/>
<input type="submit" value="Submit" /></p>
</form>
Then add verification-failed.php in the root. This can really be a plain html file. Just some kind of error message.
Anyway. That’s it. Good luck!