problem with overwritting php cookie

Posted on 2007-10-12
Last Modified: 2013-12-13
I am having a problem with cookies using php.

I have pages that track what affiliate sent me traffic, and what the keyword for the add is.

ID is the affiliates ID

I have the code below on, and

When a user click thru to
, then goes to
that has the same code below,(the same code as the cookies are overwritten from ID=100&wk=abc to values of 0., and  I can't capture the id when it is uploaded into a database.

 $ID_club = $_GET['ID'];
 $keyword = $_GET['keyword'];
setcookie("club_id_refer", $ID_club);
setcookie("club_id_refer", $ID_club, time()+3600);  /* expire in 1 hour */
setcookie("keyword_refer", $keyword);
setcookie("keyword_refer", $keyword, time()+3600);  /* expire in 1 hour */

How can I make sure that this cookie is not overwritten from the page that the user first arrives at?

Thanks for the help!
Question by:derekstattin
    1 Comment
    LVL 6

    Accepted Solution

    if (isset($_GET['ID']) && isset($_GET['keyword']) ) {
         $ID_club = $_GET['ID'];
         $keyword = $_GET['keyword'];
         setcookie("club_id_refer", $ID_club, time()+3600);  /* expire in 1 hour */
         setcookie("keyword_refer", $keyword, time()+3600);  /* expire in 1 hour */

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now