Forum Moderators: coopster
I'm trying to set a cookie based on the url and then include a file based on the cookie but i'm having some problems.
if ($_GET["currency"] = "gbp") {
setcookie("currgbp", "gbp", time()+3600, "/", ".exaxmple.com", "");
}
elseif ($_GET["currency"] = "eur") {
setcookie("currgbp", "gbp", time() - 3600, "/", ".example.com", "");
}if (isset($_COOKIE["currgbp"])){
$curr = "gbp";
} else {
$curr = "eur";
}
$p = $_GET["page"];
if (strpos($p,"..")) {
die("Bad page request");
}
if (!$p) $p = $curr;
$content_file=$_SERVER["DOCUMENT_ROOT"]."/".$p.".php";
if (!file_exists($content_file)) {
header("Location: {$_SERVER["PHP_SELF"]}");
exit();
}
include($content_file);
Normally with this when someone enter url: domain.com?currency=gbp the cookie "currgbp" will be set and the file "gbp.php" will be included.
The files are included successfully if the cookie is set correctly.
Can anyone take a look and tell me what i have done wrong with cookies?
Thanks in advance.
[edited by: eelixduppy at 3:11 pm (utc) on April 13, 2008]
[edit reason] exemplified [/edit]