amac4all Posted April 30, 2013 Share Posted April 30, 2013 Here's my cookie code: $offer = $_GET['AID'];$AdID = $_GET['Adwords'];$kw = $_GET['kw'];$combine = $AdID."-".$kw;$Month = 2592000 + time();if (isset($AdID)) {setcookie(PPC,$combine,$Month);}if ($offer == 2) {setcookie(OFFER,2,$Month);}if ($offer == 1) {setcookie(OFFER,1,$Month);} I'm basically doing A/B testing on my site with 2 different ads. When someone comes to my OFFER B landing page, I assign them a tracking cookie, then I read the cookie and present them the same offer again and again as they load other pages on the site. This ensures that they don't see my OFFER A, which is presented to regular non PPC visitors. At any rate, when someone lands on my landing page I GET the AID identifier and set it in the cookie. Unfortunately, when the visitor clicks on a second page, the cookie is removed and no longer exists. I can't find a reason for this. Any thoughts? Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 30, 2013 Share Posted April 30, 2013 Are PPC and OFFER defined somewhere as strings? The amount of code you've posted isn't much help in trying to solve your problem. Can you post the code where you check the cookies? I'm guessing PHP is assuming PPC and OFFER are strings (if they aren't defined), and converting the ints to strings, so the cookies should get set. All the logic here looks fine assuming the URL contains the correct variables. Your issue is likely to be elsewhere in your code. Quote Link to comment Share on other sites More sharing options...
amac4all Posted April 30, 2013 Author Share Posted April 30, 2013 I may be giving away my newbie status here. This is all the code I'm using to set the cookies. (I thought the PPC cookie was working fine before I started this project). I use other code to switch out the jpg offers like this: if ($_COOKIE['OFFER'] == 2) { echo '<img class="alignnone size-full wp-image-565" alt="" src="/offerb.gif" width="280" height="90" />';} else { echo '<img class="alignnone size-full wp-image-565" alt="ocpad" src="/specialoffer.gif" width="280" height="90" />';} This code is being used on a wordpress site if that helps. Quote Link to comment Share on other sites More sharing options...
amac4all Posted May 1, 2013 Author Share Posted May 1, 2013 anyone? Quote Link to comment Share on other sites More sharing options...
lemmin Posted May 1, 2013 Share Posted May 1, 2013 Put quotes around OFFER and PPC. That isn't what the problem is, but those lines are throwing warnings. You will also get one when if ANY of your GET variables aren't set. You should check for those. I think the problem is with how your variables are arriving, not with the code or logic. Try printing out your variables before you do your logic to make sure they are what you expect: echo $_GET['AID'].'<br/>'; echo $_GET['Adwords'].'<br/>'; echo $_GET['kw'].'<br/>'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.