Exemplo n.º 1
0
 function set_affiliate($result)
 {
     // Grab the affiliate cookie if set
     $cookie_affid = null;
     if (isset($_COOKIE['affid'])) {
         $cookie_affid = $_COOKIE['affid'];
     }
     // if the session affid is already set then do not process the property code
     // the cookie should always stay aligned with the session affid
     if (empty($_SESSION['affid'])) {
         // We have received a valid property code from the link server
         // Set the Session affid and the Cookie affid to link server result epire the cookie in 14 days
         // Set affiliate source to session
         if (!empty($result["property_code"])) {
             $_SESSION['affid'] = $result["property_code"];
             $_SESSION['affiliate_source'] = 'session';
             setcookie('affid', $result["property_code"], time() + 3600 * 24 * 14, '/', $this->cookie_host);
             // We have no property code returned from the link server the link was valid but the property
             // code was not formated correctly or was missing. If the cookie affid is set use that for the session affid
             // Set affiliate source to cookie
         } elseif (!empty($cookie_affid)) {
             $_SESSION['affid'] = $cookie_affid;
             $_SESSION['affiliate_source'] = 'cookie';
             // No Session affid or Cookie affid is set
             // We will use the default entity code for the site - set to the class variable $this->site_entity_code IE caseyresearch CSR
             // Set affiliate source to organic
             // We do not set a cookie for the organic because the next time they come in it would reset to cookie
         } else {
             $_SESSION['affid'] = CShell::default_affid();
             $_SESSION['affiliate_source'] = 'organic';
         }
     }
 }