Internet Explorer & Cookies Problem

Hi Guys,

I’m having a little problem with Cookies when being used with Internet Explorer, i don’t have this problem with any other browser, just Internet Explorer so your help would be very much appreciated.

Here is my code:

if($duplicateip>0){
	
			//do nothing because of duplicate lead from same IP for same campaign
						
			}else{
				
			//add lead
			//CHECK IF COOKIE EXISTS BEFORE ADDING LEAD TO DATABASE
			mysql_connect(localhost,$username,$password);
			@mysql_select_db($database) or die( "Oops theres an error, our highly trained monkeys have been notified.");

			if(isset($_COOKIE['lnm_click'])){
			
			$query = sprintf("INSERT INTO affleads VALUES ('','%s',%s,'%s',%s,%s,%s,%s,%s,%s,'%s','%s','%s','%s')",
			quote_smart($p),
			quote_smart($pname),
			quote_smart($affid),
			quote_smart($subid),
			quote_smart($adid),
			quote_smart($click),
			quote_smart($leadip),
			quote_smart($status),
			quote_smart($referer),
			quote_smart($affpayout),
			quote_smart($netpayout),
			quote_smart($datenow),
			quote_smart($timenow));
	
			mysql_query($query) or dies(mysql_error());
			mysql_close();
			}
};

For some reasons leads are not being added to the database if the browser they are using is Internet Explorer which leaves to be think it has something to do with the code that checks to see if the cookie exists or not.

Does IE block checks to see if there are cookies on the users PC or something, if you guys could help me out that would be great. Like i said it works 100% for all other browsers, just not IE.

Thank guys!

Hi there,
Try removing the @ from @mysql_select_db($database), sometimes other browsers are more forgiving than IE. Did you mean to put this in there and if so what does it do, I am curious as I have never seen it before?

That wouldn’t make any difference to how the code runs as that code runs on the server and is completely valid - it suppresses any error messages that would be otherwise generated from the database call if it were to fail for any reason.

Removing it temporarily may result in your being able to see an error message to help you to work out what is wrong.

I’ve been looking into this and add the php code to view all errors and warnings and this is what is displayed:

Notice: Undefined index: lnm_lead_affid in /home/loud/public_html/track/lead.php on line 30

Notice: Undefined index: lnm_lead_subid in /home/loud/public_html/track/lead.php on line 31

Notice: Undefined index: lnm_click in /home/loud/public_html/track/lead.php on line 32

But i know the cookies are being set as it works 100% fine in all the other browsers, just not IE.

Could you please post the rest of your code as the errors refer to three undefined variables/array items which your first snippet of code doesn’t have.

Its on about the following code:

$affid=$_COOKIE["lnm_lead_affid"];
$subid=$_COOKIE["lnm_lead_subid"];
$click=$_COOKIE["lnm_click"];

But on click.php it stores the data in the cookies and creates the cookie. Like i said it works 100% fine in all other browsers, just not IE. :frowning:

I use tools to view the cookies and can confirm the cookie exists and the data is added fine (i dont know about IE as the tool only works firefox). Below is the code on the click.php that sets the cookies

$expire=time()+60*60*24*30;
setcookie("lnm_click", "$ip", $expire);
setcookie("lnm_lead_subid", "$subid", $expire);
setcookie("lnm_lead_affid", "$affid", $expire);

Stupid question, i’m sure, but… is the IE you’re using to test set to reject cookies?

I’ve made 2 simple php pages, 1 that sets cookies and 1 that reads cookies and when i visit each one of them it sets the cookies fine and reads the cookies fine. How ever when i load the lead.php in an iframe on another site it can not find the cookies.

Why is that?

http://adamyoung.net/IE-Blocking-iFrame-Cookies

Google is my friend.

Interesting, but if i add the below to lead.php then wont it will cause a problem for the code under it as the header as already been set?

header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
setcookie('lnm_lead_subid', '',1);
setcookie('lnm_lead_clickid', '',1);
setcookie('lnm_click', '',1);

Thanks for your help StarLion, i was Googleing by the way, 24hrs actually but i never searched for that Term and i do actually remember reading about p3p on a comment someone wrote on php.net but didnt think it would have been that. Guess next time i should try everything i read :slight_smile:

You can call header more than once - so long as the headers dont mutually exclude one another, and no output has been sent to the browser.

Works :smiley:

Thank you StarLion once again!
Thank you very much!