Page 1 of 1
$_SERVER['HTTP_HOST'] as a variable
Posted: Wed Jan 05, 2011 12:04 pm
by JackTheKnife
What is different between:
$host = $_SERVER['HTTP_HOST'];
and
$host = "
www.my-domain.com";
Somehow when I have to use first line then $_SESSION vars doesn't go through two different domains.
Re: $_SERVER['HTTP_HOST'] as a variable
Posted: Wed Jan 05, 2011 12:07 pm
by Jade
Re: $_SERVER['HTTP_HOST'] as a variable
Posted: Wed Jan 05, 2011 12:12 pm
by JackTheKnife
I know what $_SERVER['HTTP_HOST'] stands for, but why is not working properly when I have declared $host variable as $_SERVER['HTTP_HOST'] but it works when I have "hard coded"?
Once again, because looks like ppl are confused what I am asking about.
I have piece of code:
Code: Select all
//$host = $_SERVER['HTTP_HOST']; //disabeld for testing
$host = "www.my-domain.com"; //dummy domain for testing
$sql = "SELECT * FROM Items WHERE LandingPageURL = '".$host."'";
.......
$landingpage = $row["LandingPage"];
...........
if ($landingpage==$host){
$_SESSION["pid"] = $product['id'];
$_SESSION["price"] = $product['price'];
...........
}
else {
echo "oops... wrong page";
}
Then I do POST form to the another site (domain) on this same server but all $_SESSION vars are empty when I have use $host = $_SERVER['HTTP_HOST'] instead of $host = "
www.my-domain.com";
Re: $_SERVER['HTTP_HOST'] as a variable
Posted: Wed Jan 05, 2011 2:00 pm
by Jade
Sessions are unique to each domain. So if you're on abc.com and you have a session, then go to def.com the session information you had for abc.com is no longer available.