608 users online (0 members and 608 guests)  

  Results 1 to 1 of 1


  1. CGI newsletter sign-up form    Forum: CGI Perl Forum
    Replies: 5
  2. Replies: 6
  3. Creating a Newsletter Group    Forum: Website Scripts Forum
    Replies: 1
  4. Replies: 1
  1. #1
    mgrunk's Avatar
    New User

    Join Date
    Jun 2008

    cookies needed for newsletter opt in

    I don't do javascript - some php, anyway, my web customer wants a pop up when someone clicks on the listen button to listen to a show. The pop up would ask them to register. If they click on register, then it shouldn't pop up again, and it shouldn't pop up for another two weeks if they decline.

    so my thought is onload -
    check to see if showregister cookie exists
    if getcookie for showregister is null
    get cookie to see if popup was displayed (2 week expire)
    if the get cookie returned null
    set cookie for popup displayed

    <script language= "JavaScript">
    function setCookie(cookieName, cookieValue, cookiePath,  
    var nowDate = new Date();  
    nowDate.setDate(nowDate.getDate() + 14);  
    cookieExpires = nowDate.toGMTString();  
    document.cookie = cookieName + "=" + cookieValue +  
    ";expires=" + cookieExpires + cookiePath;
    function getCookie(name)  
    var cookieString = document.cookie;  
    var index = cookieString.indexOf(name + "=");  
    if (index == -1)
    return null;  
    index = cookieString.indexOf("=", index) + 1;  
    var endstr = cookieString.indexOf(";", index);  
    if (endstr == -1)
    endstr = cookieString.length;  
    return unescape(cookieString.substring(index, endstr));
    function doPopup()
     var ABoTregister = getCookie('ABoTregister');
     if(ABoTregister == '') {
      var ABoTpopup = getCookie('ABoTpopup');
      if (ABoTpopup == '') {
          setCookie('ABoTpopup', 'true', '', ''); 
          // Show the popup window
          window.open('http://mydomain/ABoTregister.php', 'ABoTregister', 'toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, width=300, height=300, left=50, top=50');	  
    <body onLoad="doPopup()">
    So - it doesn't work - I don't know how to debug - every cookie example gives more info than I need.

    And, I assume that when a cookie hits the expiration date it automatically is deleted? I haven't googled that far.

    Sorry for the basic question - I've just been all over the place trying to find an answer.

    Thanks in advance.

    Last edited by vinyl-junkie; 06-09-2008 at 06:14 AM. Reason: Added code tags

Tags for this Thread