Forum Moderators: coopster
$v1 = $_GET['var1'];
$v2 = $_GET['var2'];
//set cookie time
$time_w = time()+(60*60*24*30);
//set cookies
setcookie("var1",$v1,$time_w,"/");
setcookie("var2",$v2,$time_w,"/");
// work around to get above set cookies value in corresponding variables
// without requiring a refresh/reload of the page.
$var1 = $v1;
$var2 = $v2; <?php
$v3 = $_GET['var3'];
?>
<meta http-equiv="refresh" content="0;url=<?php print htmlentities("go-out.php?var3=$v3"); ?>" /> include "script2.php";
if ($v3 == "something") {$link = "http://www.example.com";}
header("Location: $link$all");
$t1 = $_COOKIE['var1'];
$t2 = $_COOKIE['var2'];
$v3 = $_GET['v3'];
$all = "$t1^$v3^$t2"; But as I browse through the website cookies disappear.
$v3 = $_GET['v3'];
error_reporting(E_ALL);
ini_set('display_errors','1'); // Unless you have alternative error logging
That's presumably when you don't click on an outgoing link? So, "go.php", "go-out.php" and "script2.php" are not processed at this point?
Do the cookies literally "disappear", or are they set to an empty string?
How are you calling script1 from .htaccess?
[edited by: smallcompany at 7:20 pm (utc) on Feb 23, 2016]
if (isset($_GET['var1'])) {
$v1 = $_GET['var1'];
}
if (isset($_GET['var2'])) {
$v2 = $_GET['var2'];
}
$time_w = time()+(60*60*24*30);
setcookie("vv1",$v1,$time_w,"/");
setcookie("vv2",$v2,$time_w,"/");
$vv1 = $v1;
$vv2 = $v2; The notices refer to v1 and v2. Shouldn't IF and ISSET prevent it?
// Check that cookie is set first
$v1 = isset($_COOKIE['vv1']) ? $_COOKIE['vv1'] : null;
$v2 = isset($_COOKIE['vv2']) ? $_COOKIE['vv2'] : null;
// But allow value passed in URL to override cookie (?)
$v1 = isset($_GET['var1']) ? $_GET['var1'] : $v1;
$v2 = isset($_GET['var2']) ? $_GET['var2'] : $v2;
// Only set cookie if we have something to set, or proceed anyway?
if ($v1 && $v2) {
// Set cookies....
$time_w = time()+(60*60*24*30);
setcookie('vv1',$v1,$time_w,'/','.example.com');
setcookie('vv2',$v2,$time_w,'/','.example.com');
}
$vv1 = $v1;
$vv2 = $v2;
$t1 = $_COOKIE['vv1'];
$t4 = $_COOKIE['vv4'];
if (isset($_COOKIE['vv1'])) {
$t1 = $_COOKIE['vv1'];
}
if (isset($_COOKIE['vv1'])) {
$t1 = $_COOKIE['vv1'];
}
else {
$t1 = "(Not Provided)";
}
$t1 = isset($_COOKIE['vv1']) ? $_COOKIE['vv1'] : "(Not Provided)";
For the most important result - tracking variables - I'll have to wait for an hour or two to see new sales in reporting.
I'm still puzzled why it did stop working at the first place.
If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client. This is internally achieved by setting value to 'deleted' and expiration time to one year in past.