Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/56120-embarrassing-question/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/56120-embarrassing-question/#findComment-277208
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/56120-embarrassing-question/#findComment-277212
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.