SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2007
    Posts
    398
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie created upon click?

    Hi All,

    Have a quick question on cookies. On my site i'm running a survey and have three options:

    1. Do the Survey (Link Goes through to the survey)
    2. Don't do the Survey and don't show me this page again (creates a cookie)
    3. Do the survey next time (just javascript:close)

    Now my problem is with option 2 As you see I create a cookie, but this cookie is always created everytime the pages is loaded. I only need it to be created if No Thanks, don't show me again is clicked. Can this be done in php?

    Thanks

    PHP Code:

    <!-- YES I'LL DO IT  -->
    <div class="left_feature">
     <p><a href="http://www.sdjsdfsfsdjjdjdj.com/survey.php">Yes i'll do it</a></p>
    </div>

    <!-- NO THANKS AND DON'T SHOW ME AGAIN  -->
    <div class="middle_feature">
    <?php
    // Set a cookie for a month and this dhtml object will not appear
      
    $expire=time()+60*60*24*30;
      
    setcookie("cookie_var""dasurvey"$expire);
      echo 
    "<a href=\"javascript:window.close()\">No Thanks, don't show me again</a>";
    ?>
    </div>

    <!-- NEXT TIME  -->
    <div class="right_feature">
    <a href="javascript:window.close()">Next Time</a>
    </div>

  2. #2
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, you'll need to create the cookie using Javascript's document.cookie.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •