I got stumped doing age verification and am wondering what's the best way now. It does not have to be robust, my initial plan was using jquery.
I found this resource,
http://www.techerator.com/2010/09/how-to-perform-age-verification-with-jquery-and-cookies-mmm-cookies/
For ease of use, I have pasted the method here:
Used on pages that need verification
if ($.cookie('is_legal') == "yes") {
//legal!
} else {
document.location = "http://www.domain.com/[pathtofile]/verify.php?redirect=http://<?php echo $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ?>";
}
The verification page
$('#accept-btn').click(function(){
$.cookie('is_legal', 'yes', { expires: 1, path: '/', domain: 'domain.com' });
<?php if ( !isset($_REQUEST['redirect']) || $_REQUEST['redirect'] == "" ) { ?>
document.location = "http://www.domain.com";
<?php }else{ ?>
document.location = "<?php echo $_REQUEST['redirect']; ?>";
<?php } ?>
});
here is the html part of it.
<p>Are you OVER 18</p>
<div id="accept-btn">YES</div>
<div id="noaccept-btn"> NO</div >
First issue is that the else statement is not working, as well it seems to be using the same variable for the redirect for the YES option and the NO option.
SO I am curious, just for learning sake, why this is not working properly and how to fix, and secondly what's really the better way here. Like I said seo/php or a robust way is not critical.
My desired result is that, when they access any page on the site they get a yes or no option and then, when YES they get access to the page, if they choose no, it's a redirect.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…