我目前正在尝试进行 PHP 调用以在用户首次登陆页面时接收由以下代码块设置的 cookie
if (empty($_COOKIE["uuid"])) {
$uuid = uniqid(); // or use a real UUID
setcookie("info", $uuid, $thisAid, $thisSubID, $thisURL, time()+30*24*60*60, "/");
}
else {
$uuid = $_COOKIE["uuid"];
foreach($_COOKIE as $name => $uuid){
// you can check any conditions based on cookie name $name
$cookiequery = "INSERT INTO table_name(WebTraffic) VALUES(" . mysql_escape_string($uuid) . ##")";
mysql_query($cookiequery);
unset($cookiequery);
然后在用户点击特定页面以从 cookie 中获取值并将其添加到数据库时向数据库添加另一行
if (isset($_COOKIE["uuid"]))
$values = '';
$sql = " INSERT INTO WebTraffic (aid, subID, campaignID, URL, uuid) VALUES(";
foreach ($_COOKIE as $name => $uuid)
$values .= "'$uuid'";
$sql .= $values.")";
但两者都没有工作,有人能指出我正确的方向吗?谢谢!
编辑:这些值是前面设置的字符串:
$thisAID = $_GET['aID'];
$thisSubID = $_GET['subID'];
$thisCampaignID = $_GET['campaignID'];
$thisURL = $_SERVER['REQUEST_URI'];
$uuid = uniqid();
从传递的 URL 中提取