John
02-18-2003, 12:23 PM
This is some code I wrote to extract the subdomain prefix from a subdomained site. I then assign a session variable with that value to use in the main site.
The subdomain I am using for experiements is http://az.citysave.net
<?php
session_start();
$stateAddress = $_SERVER["PATH_TRANSLATED"];
$stateAddressArray = explode(".", $stateAddress);
$stateAbreviation = explode("/", $stateAddressArray[0]);
$state = $stateAbreviation[count($stateAbreviation) - 1];
$_SESSION['state'] = $state;
header("Location: http://www.citysave.net/");
exit;
?>
Here is the index.php code for the site www.citysave.net
<?php
session_start();
// echo "State = ".$_SESSION['state'];
// This only prints out "State = " with no value for the session variable.
if(isset($_SESSION['state']))
{
$stateAbreviation = $_SESSION['state'];
$bodyContent = '
<form name="form1" method="post" action="submission.html">
<div align="center">Enter your city code here:
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</div>
</form>
';
}
else
{
$stateAbreviation = '';
$bodyContent = '<form name="form1" method="post" action="azindex.html">
<div align="center">
<p>Select your state:
<select name="select">
<option>Arizona</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Go">
</p>
</div>
</form>
';
}
include("phf.inc.php");
?>
I am using files to handle the sessions, but the session variable "state" does not come through.
To see the session settings for the server, go to www.citysave.net/phpinfo.php
Any suggestion would be greatly appreciated!
Thanks!
PS.
These scripts work just fine on my local machine, but don't on the remote host.
There are two differences between the two that I think may be significant, but I'm not sure how.
They are:
local: PHP v 4.2.3 and session.use_trans_sid = 0
remote: PHP v 4.2.2 and session.use_trans_sid = 1
Anyone?
The subdomain I am using for experiements is http://az.citysave.net
<?php
session_start();
$stateAddress = $_SERVER["PATH_TRANSLATED"];
$stateAddressArray = explode(".", $stateAddress);
$stateAbreviation = explode("/", $stateAddressArray[0]);
$state = $stateAbreviation[count($stateAbreviation) - 1];
$_SESSION['state'] = $state;
header("Location: http://www.citysave.net/");
exit;
?>
Here is the index.php code for the site www.citysave.net
<?php
session_start();
// echo "State = ".$_SESSION['state'];
// This only prints out "State = " with no value for the session variable.
if(isset($_SESSION['state']))
{
$stateAbreviation = $_SESSION['state'];
$bodyContent = '
<form name="form1" method="post" action="submission.html">
<div align="center">Enter your city code here:
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</div>
</form>
';
}
else
{
$stateAbreviation = '';
$bodyContent = '<form name="form1" method="post" action="azindex.html">
<div align="center">
<p>Select your state:
<select name="select">
<option>Arizona</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Go">
</p>
</div>
</form>
';
}
include("phf.inc.php");
?>
I am using files to handle the sessions, but the session variable "state" does not come through.
To see the session settings for the server, go to www.citysave.net/phpinfo.php
Any suggestion would be greatly appreciated!
Thanks!
PS.
These scripts work just fine on my local machine, but don't on the remote host.
There are two differences between the two that I think may be significant, but I'm not sure how.
They are:
local: PHP v 4.2.3 and session.use_trans_sid = 0
remote: PHP v 4.2.2 and session.use_trans_sid = 1
Anyone?