Reputation: 199
I am having trouble setting and echoing out a cookie, I was wondering if you could help me out, I am relatively new to php but I can work my way around. Here is the code...
if (empty($_COOKIE['source'])) {
$kw = $_SESSION["keyword"];
//echo $kw;
$needle = array(
"bomanite"
);
if (multineedle_stripos($kw, $needle) || $engineName == 'Direct' || $engineName == '') {
// branded search, don't display lead tracking phone/email
$source = "direct";
$liveemail = "[email protected]";
$livephone = "<span id='bom-phone'>Call us for a Quote: (416) 800 5545</span>";
} elseif ($engineName == 'ppc') {
$source = "ppc";
$liveemail = "[email protected]";
$livephone = "<span id='bom-phone'>Call us for a Quote: (416) 800 5446</span>";
} else {
$source = "organic";
$liveemail = "[email protected]";
$livephone = "<span id='bom-phone'>Call us for a Quote: (905) 660 5545</span>";
}
setcookie("source", $source, time() + (60 * 60 * 24 * 30), '/', 'bomanite.cidev.info/');
setcookie("kw", $kw, time() + (60 * 60 * 24 * 30), '/', 'bomanite.cidev.info/');
setcookie("liveemail", $liveemail,time() + (60 * 60 * 24 * 30), '/', 'bomanite.cidev.info/');
setcookie("livephone", $livephone,time() + (60 * 60 * 24 * 30), '/', 'bomanite.cidev.info/');
} else {
$source = $_COOKIE['source'];
$kw = $_COOKIE["kw"];
$liveemail = $_COOKIE['liveemail'];
$livephone = $_COOKIE['livephone'];
}
?>
Upvotes: 0
Views: 372
Reputation: 122
Cookies are very sensitive to path.. Can you try this?
setcookie("source", $source, time() + (60 * 60 * 24 * 30), '/');
Upvotes: 1
Reputation: 101473
Make sure there is no other output to the client before the setcookie()
call. Because it uses HTTP headers, no output can precede it.
This may be a typo in your question, but you need an opening <?php
tag at the top of your file.
Upvotes: 0