Note that there are some explanatory texts on larger screens.

plurals
  1. POAge Verification
    text
    copied!<p>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.</p> <p>I found this resource, <a href="http://www.techerator.com/2010/09/how-to-perform-age-verification-with-jquery-and-cookies-mmm-cookies/" rel="nofollow">http://www.techerator.com/2010/09/how-to-perform-age-verification-with-jquery-and-cookies-mmm-cookies/</a></p> <p>For ease of use, I have pasted the method here:</p> <p><strong>Used on pages that need verification</strong></p> <pre><code>if ($.cookie('is_legal') == "yes") { //legal! } else { document.location = "http://www.domain.com/[pathtofile]/verify.php?redirect=http://&lt;?php echo $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; ?&gt;"; } </code></pre> <p><strong>The verification page</strong></p> <pre><code>$('#accept-btn').click(function(){ $.cookie('is_legal', 'yes', { expires: 1, path: '/', domain: 'domain.com' }); &lt;?php if ( !isset($_REQUEST['redirect']) || $_REQUEST['redirect'] == "" ) { ?&gt; document.location = "http://www.domain.com"; &lt;?php }else{ ?&gt; document.location = "&lt;?php echo $_REQUEST['redirect']; ?&gt;"; &lt;?php } ?&gt; }); </code></pre> <p>here is the html part of it. </p> <pre><code>&lt;p&gt;Are you OVER 18&lt;/p&gt; &lt;div id="accept-btn"&gt;YES&lt;/div&gt; &lt;div id="noaccept-btn"&gt; NO&lt;/div &gt; </code></pre> <p>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. </p> <p>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. </p> <p>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. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload