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.
$_SERVER['HTTP_HOST'] as a variable
Moderator: General Moderators
-
JackTheKnife
- Forum Newbie
- Posts: 3
- Joined: Sat Dec 19, 2009 8:08 am
Re: $_SERVER['HTTP_HOST'] as a variable
You need to read this page in the php manual: http://www.php.net/manual/en/reserved.v ... server.php
-
JackTheKnife
- Forum Newbie
- Posts: 3
- Joined: Sat Dec 19, 2009 8:08 am
Re: $_SERVER['HTTP_HOST'] as a variable
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:
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";
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
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.