<?php

  /* set expiration time of cookies */
  $expires_seconds        = 0;
  $expires_minutes        = 0;
  $expires_hours          = 0;
  $expires_days           = 0;
  $expires_months         = 6;
  $expires_total          = ($expires_seconds + ($expires_minutes * 60)
                            + ($expires_hours * 60 * 60) + ($expires_days * 60 * 60 * 24)
                            + ($expires_months * 60 * 60 * 24 * 30));
  /* end "set expiration time of cookies" */
                                                                


  /* if there is no cookie yet, set one */
  if (!isset($_COOKIE['poll'])) {
    setcookie("poll","poll_allowed",(time()+$expires_total),"/",$this->cookie_domain);
    header("Location: \"http://".($this->cookie_domain)."\"");
    exit;
  }
  /* end "if there is no cookie yet, set one" */
                                                                            


  /* if there was a cookie already set... */
  else {
                                                                                                
    // user allowed to vote and is voting now
    if (($_POST['poll_action'] == "vote") and ($_COOKIE['poll'] != "poll_voted")) {
      setcookie("poll","poll_voted",(time()+$expires_total),"/",$this->cookie_domain);
    }
    // end "user allowed to vote and is voting now"
                                                                          
    // to prevent a reload bug
    if (($_COOKIE['poll'] == "poll_voted") and ($_POST['poll_action'] == "vote")) $_GET['poll_stats'] = "yes";
    // end "to prevent a reload bug"
                                                                                                                                          
  }
                                                                                                                                              /* end "if there was a cookie already set..." */
                                                                                                                              
                                                                                                                                              ?>
