Results 1 to 8 of 8
  1. #1

    setting a cookie - referrer

    Does anyone know how to set a cookie, that tells where the user came from when they enter your main page. Then, even if they come back a week later, (doesn't matter where they come from) and then place an order, have the order form report the refferer contents of the cookie to you, so you can possibly track where that original reffer cam from. Is this possible? if so, how do you do it?

    Thanks.

  2. #2
    If you know a little php you could to it with www.php.net/setcookie

    Of course you would want to enclose it in an if statement to check whether they already have the cookie present from a previous visit. Something like this

    PHP Code:
    <?php
    if (empty($referer)){
    setcookie ("referer"$HTTP_REFERER,time()+2592000); 
    }
    ?>
    Make sure that this code is at the very top of the page without even any white space before it. It should be before your opening <html> tag.

    Then you would have to echo it into your form by putting the following code where you want it.

    PHP Code:
    <?=$referer ?>
    Of course, the pages with this code will need to have .php extensions.
    Marty Hoskins
    http://tlcwe.com

  3. #3
    thanks! that set the cookie. Now.. As to implementing this in my order form..

    Look near the bottom, and you can see the referrer part. It doesn't come through when someone submits an order form though. How woould I make it correctly come through e-mail?

    <?

    include("ordercomplete.inc.php");
    $message = "<HTML>\n";

    $message .= "<b>Reseller Web Host Order Form</b><br>\n<br>\n";
    $message .= "<i>Personal Information</i><br>\n";
    $message .= s_bar();
    $message .= s_table();
    $message .= s_item("Name",$name);
    $message .= s_item("Organization",$org);
    $message .= s_item("Address",$address);
    $message .= s_item("City", $city);
    $message .= s_item("State", $state);
    $message .= s_item("Country", $country);
    $message .= s_item("Zip", $zip);
    $message .= s_item("Phone", $phone);
    $message .= s_item("E-Mail", $email);
    $message .= s_item("Referral",$where);
    $message .= s_item("Other", $where2);
    $message .= s_etable();
    $message .= s_next("Ordering Information");
    $message .= s_item("Registration", $regyn);

    if ($domain)
    $message .= s_item("Domain Name", $domain);

    $message .= s_item("Package", $pack);
    $message .= s_item("Payment Frequency",$pfreq);
    $message .= s_etable();
    $message .= s_next("<i>Credit Card Information</i><br>\n");
    $message .= s_item("Card Type", $poptions);

    /* introduction of $mmessage */
    // sprintf($mmessage, "%s", $message);
    $mmessage = "$message";
    $mmessage .="<tr><td width='20%'>Card Number :</td><td>";
    if (strlen($cnumber) > 14)
    {
    $mmessage .= str_repeat("*", 12);
    $mmessage .= substr($cnumber, 12);
    } else $mmessage .= "<b>Not Displayed</b>";
    $mmessage .= "</td></tr>\n";

    $message .= s_item("Card Number", $cnumber);
    $message .= s_item("Expiration Date", $expiration);
    $message .= s_item("Name on card", $cname);
    $message .= s_next("Misc.");

    $mmessage .= s_item("Expiration Date", $expiration);
    $mmessage .= s_item("Name on card", $cname);
    $mmessage .= s_next("Misc.");
    $mmessage .= s_item("IP Address",$REMOTE_ADDR);
    if ($terms)
    {
    $message .= s_item("Accepted AUP", "Yes");
    $mmessage .= s_item("Accepted AUP", "Yes");
    }

    $message .= s_item("IP Address",$REMOTE_ADDR);
    if ($S1)
    {
    $message .= s_item("Special Instructions", $S1);
    $mmessage .= s_item("Special Instructions", $S1);
    }
    $message .= "$referer";
    $message .= "</table><br><center><b>-- End of message --</b></center><br>\n";
    $mmessage .= "</table><br><center><b>-- End of message --</b></center><br>\n";

    if ($terms != "0")
    {
    printdenied("<br><H3>Sorry, but you must accept the terms of service before you continue. <a href='javascript:history.go(-1)'>Back</b><a><br>\n");
    exit;
    } else if (!$domain) {
    printdenied("<br><H3>Sorry, but you must enter a domain name to use before you continue. <a href='javascript:history.go(-1)'>Back</b><a><br>\n");
    exit;
    } else {
    mail("[email protected]","RESELLER Hosting Request for $name",$message, "From: [email protected]\nOrder-form: True");
    mail("[email protected]","RESELLER Hosting Request for $name",$message, "From: [email protected]\nOrder-form: True");
    printme($mmessage);
    }
    ?>

  4. #4
    Join Date
    May 2002
    Posts
    344
    Try changing

    Code:
    $message .= "$referer";
    to

    Code:
    $message .= $referer;
    Chris Miller
    PromoPunch
    Custom Imprinted Promotional Products
    www.promopunch.com 1-800-750-8530 x221

  5. #5
    Nope. That didn't work..

  6. #6
    Join Date
    May 2002
    Posts
    344
    Sounds like the cookie isnt getting set then.

    Try to make a new file:

    PHP Code:
    <?
    echo $referer;
    ?>
    If it doesnt echo the referer to the screen, the cookie is most likely not set.
    Chris Miller
    PromoPunch
    Custom Imprinted Promotional Products
    www.promopunch.com 1-800-750-8530 x221

  7. #7
    No, that works. It echos the reffer just fine.

  8. #8
    Join Date
    May 2002
    Posts
    344
    <snip> its obviously been a while since Ive played with php </snip>
    Chris Miller
    PromoPunch
    Custom Imprinted Promotional Products
    www.promopunch.com 1-800-750-8530 x221

Posting Permissions

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