0

Hi everyone, I have a website and need a age verification so young kids can't visit my website. I have a code and works well but it's constantly asking age verification in any page I visit my website. Can anyone help me on how to configure this code so it only ask once for age verification, thanks in advance.

    <script type="text/javascript">// <![CDATA[
    var agePrompt=prompt("What is your age?");

    if (agePrompt>=18) alert('Welcome!')
    else {
    alert('Sorry! Come back in a few years!')
    document.location="https://www.1adslinks.com/MISC/adult";

    }
    // ]]></script> 
3
Contributors
5
Replies
6
Views
4 Years
Discussion Span
Last Post by james chaco
0

Any server side code such as PHP or ASP.NET? If so, store the results of the age in a session variable so you can carry the value from one page to another.

0

Hi Jorge, sorry I don't understand what you mean by store the results of the age in a session variable. I don't want to carry the value to the next page. I want one time cookie where visitor visits the site and has to confirm his/hers age one time only. Thanks for answering.

0

Ok, so if you create a cookie, you simply need to check the value stored in that cookie on each page. If the cookie exists and the value stored is greater than the required value, then you dont prompt the user again. If the value is less, redirect the user letting them know they are not able to access your content. If there is no cookie, then prompt the user.

The session variable is also stored as a cookie, but destroyed at the end of the web browser session.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.