Hey. Check: first.
Then here is my question.
I want to include cookies in my scripts.
Perpase: When someone posts a new comment i want the link ([x comments] to get a color or something. So for that i need to write a cookie.
The news is store in a DB with a newsid ($nieuwsid) and $comments (number of comments in a newsitem).
I've got this so far (the code is at the bottom of the script. So after the page is generated it should write a cookie):
setcookie($nieuwsid,$comments,time() + 31536000,'/','.hotseflots.com',0);
But as i think about what it does, I get stuck. Because if (for example) $nieuwsid = 54 then it stores a cookie with value $comments (for example = 5)
So now there is a cookie named 54 with a value of 5.
Maybe i'm wrong. I'm a incredible n00b!
So then if I call the cookie like this:
<?php
if ($_COOKIE[$nieuwsid] > $comments) {
echo"$commentsnaam <font color=\"#FFCC33\">NEW!</font></b> ]</b> </font></td>";
} else {
echo"$commentsnaam </b> ]</b> </font></td>";
}
?>
It says: if cookie named 54 has a value larger then 5, echo NEW!
else: dont echo NEW!
Can someone help me?
I don't get it. 🙁