eggerda Posted June 18, 2007 Share Posted June 18, 2007 Hello, I'm a beginner, and I told someone I knew more than I did...now I've got to figure this out. This is simple for anyone that knows what they are doing...and unfortunately, I don't. Basically I need the simplest code to accomplish the following: When a visitor comes to a page, I need to check for a cookie... if the cookie is empty I need to write out a line of html code (a tracking image). If the cookies has an "X" value in it, I don't want to display the line of html code (the tracking image). This is supposedly easy, but I've been struggling to get it to work write. How would you do it? Any thoughts are appreciated. Thanks, Dan Quote Link to comment https://forums.phpfreaks.com/topic/56120-embarrassing-question/ Share on other sites More sharing options...
teng84 Posted June 18, 2007 Share Posted June 18, 2007 the answer is also here When a visitor comes to a page, I need to check for a cookie... if the cookie is empty I need to write out a line of html code (a tracking image). If the cookies has an "X" value in it, I don't want to display the line of html code (the tracking image). and if the cookie is empty { write out a line of html code } else { display the line of html code (the tracking image) } you've already answered your question Quote Link to comment https://forums.phpfreaks.com/topic/56120-embarrassing-question/#findComment-277208 Share on other sites More sharing options...
eggerda Posted June 18, 2007 Author Share Posted June 18, 2007 Yes, but I'm having a hard time writing the code...it's just not working... I don't know what I'm doing wrong. At the top of the page I have: <? if (empty($_COOKIE['TrackThis'])) { $code = "http://trackingcode.com"; setcookie("TrackThis", $random_number, time()+60*60*24*30*12); } ?> The in the body I have: <? echo $code ?> What did I do wrong? Dan Quote Link to comment https://forums.phpfreaks.com/topic/56120-embarrassing-question/#findComment-277212 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.