Beginner at php. Have an age gate page where users have to click on age verification before proceeding to site. Currently everything works, but need redirect to work for urls that are provided to user. So if I provide a link to the about page they are redirected to that page after verifying age.
This is my current code
$cookie_name = "ageVerify";
$cookie_value = "1";
setcookie($cookie_name, $cookie_value, time() + (86400 * 3), "/"); // 86400 = 1 day
header("Location: index");
Here’s the snippet:
if(!$_COOKIE['ageVerify']) {
header("Location: http://domain.com/age-gate");
exit;
}
I’ve tried to store the url and call in the header but that doesn’t work
$referer = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
setcookie(‘age_referer’, $referer, 0, “/“);
header("Location: age_referer");
Any help would be greatly appreciated!