I'm using the Advanced Poll, but also having problems with the cookies. I don't care if people vote several times. But, when I leave the include out, then my poll does not work (press the Vote button and no action).
I think there is a problem with the code. Does the code below seem correct? I think the if statement is backwards. In that, it should say if (headers_sent()) and not negative.
Here's the poll_cookie.php code.
<?php
/**
* ----------------------------------------------
* this code is optional
* Important! You have to include it
* before your html code
* ----------------------------------------------
*/
if (!headers_sent()) {
$cookie_expire = 96; // hours
$action = (isset($HTTP_GET_VARS['action'])) ? $HTTP_GET_VARS['action'] : '';
$action = (isset($HTTP_POST_VARS['action'])) ? $HTTP_POST_VARS['action'] : $action;
$poll_ident = (isset($HTTP_GET_VARS['poll_ident'])) ? $HTTP_GET_VARS['poll_ident'] : '';
$poll_ident = (isset($HTTP_POST_VARS['poll_ident'])) ? $HTTP_POST_VARS['poll_ident'] : $poll_ident;
if ($action=="vote" && (isset($HTTP_POST_VARS['option_id']) || isset($HTTP_GET_VARS['option_id']))) {
$cookie_name = "AdvancedPoll".$poll_ident;
if (!isset($HTTP_COOKIE_VARS[$cookie_name])) {
$endtime = time()+3600*$cookie_expire;
setcookie($cookie_name, "1", $endtime);
}
}
}
?>