Ciao ragazzi,
ho il seguente codice:
<?php
error_reporting(E_ALL);
//ob_start();
if($_GET['saref']){
//someone is coming to this page with a get string that starts with ref=something
//we need to id the offer and get some info
include "sa_config.php";
$con = sa_db_connect();
if(!$con){
//could add some kind of admin email message here
}
//split the saref into its parts
list($offerID, $affiliateID) = explode("sa", $_GET['saref']);
//echo "IDs:".$offerID.$affiliateID;
$q1 = "SELECT * FROM Offers WHERE OfferID = '$offerID' ";
$result1 = mysql_query($q1);
$row1 = mysql_fetch_array($result1);
if(mysql_num_rows < 1){
//we have someone trying to access with an invalid offer id we should email the admin about this
}
$cookieExpiration = $row1[CookieExpire];
if($cookieExpiration > 0)
$cookieLifetime = time() + $cookieExpiration;
else
$cookieLifetime = time() + 3650*86400;
SetCookie ("saref",$_GET['saref'], $cookieLifetime, $cookiePath, $cookieDomain);
SetCookie ("saref",$_GET['saref'], $cookieLifetime, $cookiePath, $cookieDomain);
SetCookie ("saref",$_GET['saref'], $cookieLifetime, $cookiePath, $cookieDomain);
SetCookie ("saref",$_GET['saref'], $cookieLifetime, $cookiePath, $cookieDomain);
SetCookie ("saref",$_GET['saref'], $cookieLifetime, $cookiePath, $cookieDomain);
if(session_id() == ""){
session_start();
}
$_SESSION['ref'] = $_GET['saref'];
$timeNow = date("U");
$q1 = "INSERT INTO Clicks (AffiliateID, OfferID, UnixTime, RemoteAddress, RefURL, Browser) VALUES
('".$affiliateID."', '".$offerID."', '".$timeNow."', '".$clickIP."', '".$clickURL."', '".$clickBrowser."')";
$result1 = mysql_query($q1);
//echo $q1;
}
//ob_flush();
echo $HTTP_COOKIE_VARS["saref"] . "---";
?>
Stranamente quando ( con l'ultima istruzione ) tento di stampare il valore del cookie ottengo solo: --- ( quindi il cookie non è stato valorizzato ).
Ho fatto anche un echo del valore $_GET['saref'] ed è tutt'ok ( è valorizzato ).
Come mai il cookie non viene settato?
![]()