Hey all, I've been working on this poll and I thought it would be nice to have a cookie in it, since I don't want anybody voting more than once.
Ok, I have three files:
header.php - this is the "nav" menu
index.php - this is the part where the cookie gets set..
footer.php - this is the page that has the poll in it which redirects to index.php?action=results&post=yes
Ok, When I go to index.php, the header.php en the footer.php are included, so you see both the menu and the poll.
When you click on VOTE on the poll, you go to index.php?action=results&post=yes.
In index.php, on the top line, I have the following code:
(the poll_id DOES get sent when you submit the poll...
<?
if ($action=="results"&&$post=="yes")
{
setcookie("poll_id",$poll_id,Time()+604800);
}
if ($action=="results"&&$post=="no")
{
setcookie("poll_id",$poll_id);
}
?>
After this the includes for the header.php and the footer.php.
I've added the following code to the footer to check if there'a a cookie set:
<?
if ($HTTP_COOKIE_VARS["poll_id"])
{
echo"cookie present";
}
else
{
echo"no cookie";
}
?>
But when I go to index.php again, it keeps saying that there's NO cookie present. But when I browse to footer.php it says there is a cookie.
So I think the problem is with the include function, since including footer.php does NOT show the cookie, but browsing to footer.php DOES..
Please Help me 😛
Menno