Hi again, not a detailed tutorial. I can give you some more general instructions and the buildings blocks how to achieve this.
First the modal dialog, which is more modern than redirecting to another website.
THere is a nice jquery plugin called JQuery BlockUI Plugin.
Than you have to read and write cookies which can be dont with this function in PHP
The code is from here without the base64 encryption.
Code:
/*
@param $name - Name of Cookie
@param $default - Default value, if the specified cookie does not exist
*/
function readCookie($name, $key = null, $default=null){
if(isset($_COOKIE[$name])){
$val = $_COOKIE[$name];
return $val;
}else{
return $default;
}
}
Check for the value of the cookie
Code:
$ageCheck = readCookie('AgeVerification');
if (is_null($ageCheck) || $ageCheck != '>21' )
{
//show the modal window with the age verification text, read the tutorial about the jquery BlockUI Plugin how too show this.
}
Later you have to write a cookie with javascript or php after the age verification checkbox was clicked on the Modal Dialog and close the dialog.
Code:
/*
@param $name - Name of cookie
@param $val - Value of the cookie
@param $time - Life of the cookie in seconds
@return TRUE on success else FALSE
*/
function writeCookie($name, $val, $time = null){
$time = is_null($time) ? $GLOBALS['cookieLife'] : $time;
// Save the cookie if header is not already sent
if(!headers_sent()) {
return setcookie($name, $val, time() + $time, '/');
}else{
return FALSE;
}
}
writeCookie('AgeVerification','>21', 60*24*7); // that lasts a week, so visitors see the age check after a week again. Check the age as you like.
Thats about it. The code has to be added in includes/application_top.php
The javascript files for the plugin and jquery should be copied to /includes/templates/YOUR_TEMPLATE/jscript/