Announcement

Collapse
No announcement yet.

Age Verification cookie

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Age Verification cookie

    OK maybe somebody can lend a hand.

    One of my sites requires age verification. The code is all written and for awhile worked fine. Suddenly I now get the popup on every page instead of just the first visit of the session.

    The script creates a cookie. Then each page checks for the cookie to be present and should ignore the script if it is.

    It seems that the transition to some https pages triggers the problem. If I start a new session it works fine until I visit an https page and then it no longer works.

    Here is the cookie creation.
    Code:
    $(function(){if($.cookie('ageVerify')!='true'){$.fn.colorbox({overlayClose:false,escKey:false,inline:true,href:'#verify-age'},function(){$('#cboxClose').hide();$('#verify-age a[rel=true]').click(function(){$.colorbox.close();});$('#verify-age a[rel=false]').click(function(){document.location='http://google.com/';});});}
    $('#verify-age a[rel=true]').live('click',function(){$.cookie('ageVerify','true');});});jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}
    var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
    expires='; expires='+date.toUTCString();}
    var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
    return cookieValue;}};
    Last edited by Ruppy; 02-08-2014, 02:15 PM.

  • #2
    just a hunch, and im going off of the https statement. Is this a problem with jquery / prototype conflict? the checkout pages use prototype and that gave me all sorts of stupid issues till i found that.

    Comment


    • #3
      Hmm thats a good question. Can I use no conflict with prototype and jquery? Ive done it for two versions of jquery to fix quicksearch.
      Last edited by Ruppy; 02-08-2014, 02:19 PM.

      Comment


      • #4
        The trigger on each page
        Code:
        <div style="display: none;">
          <div id="verify-age">
              <center><h2><img src="logo.png" alt="Logo" /></h2></center>
            <div class="age-option" style="vertical-align: middle;">
            <p class="legal-age">Are you 18 years of age or older?</p><br>
        
            
                <a href="#" class="over-18" rel="true"><img src="assets/images/Enter.png"></a>
          OR
                <a href="http://google.com/" class="under-18" rel="false"><img src="assets/images/exit.png"></a>
         
            </div>
            <p>This site is intended for use by adults of legal age<br /> in their state, province, or country.</p>
          </div>
        </div>
            
            <script src="colorbox/jquery.colorbox.js" type="text/javascript"></script>
            <script src="colorbox/age.colorbox.js" type="text/javascript"></script>
        I cant post the main part of the jquery as apparently its too long

        Comment


        • #5
          pm me the page url. i'll take a look at it?

          Comment


          • #6
            ok so after looking at the site-

            I don't have a whole lot of experience with cookies as i rarely use them, but from what I can see, the cookies you are using are indeed http only. I found this article doing a bit of google searching that touches on your issue as well. given the fact that you don't have server side access, i'm wondering if its viable to create https cookies from the client side considering theres no certificate to sign them with?

            JQuery Cookie values not maintained while moving from http to https - Stack Overflow

            Comment


            • #7
              Originally posted by jleclair View Post
              ok so after looking at the site-

              I don't have a whole lot of experience with cookies as i rarely use them, but from what I can see, the cookies you are using are indeed http only. I found this article doing a bit of google searching that touches on your issue as well. given the fact that you don't have server side access, i'm wondering if its viable to create https cookies from the client side considering theres no certificate to sign them with?

              JQuery Cookie values not maintained while moving from http to https - Stack Overflow
              Then it seems navigating to HTTPS must trigger a new session in the browser. Hence why navigating back to a http page still cant find the session cookie.. Such a problem for a cookie that carries no sensitive data.

              Guess its time for some research..

              Odd that this worked for quite awhile and then just stopped. I ran a test order this morning which is what started it.

              Thanks a ton for a new set of eyes.

              Comment

              Working...
              X