Posted by Flaming Corncob on 08/19/06 13:13
Below is the code I'm working on. Unfortunately it keeps looping through
the function reroute_session(). How it's supposed to work: First it
checks to see if the session is registered. If it's not, it registers a
session and links back to the page with header(). The second thing it
checks is the $base link to the referring link stored in $base_ref. If
they aren't equal it reroutes the page back through header() to set the
page to home.
<?
session_start();
// $base = Location of this site.
$base=$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$url=parse_url($_SERVER['HTTP_REFERER']);
// $base_ref = Refered link constructed from $url.
$base_ref=$url['host'].$url['path'];
if(!session_is_registered("account_id"))
// If TRUE: Session needs to be registered.
{
register_session($base);
}
else if($base_ref!=$base)
// If TRUE: Visited from a site other than this one. Reroute to set page
to home. Trouble is this portion keeps looping.
{
reroute_session($base);
}
else
{
echo "<html>";
echo "<body>";
echo "Hello, ".$_SESSION['user_id']."!";
echo "</body>";
echo "</html>";
}
function register_session($base)
{
session_register("account_id");
session_register("user_id");
$_SESSION['user_id']="guest";
header("Location:http://$base?page=home");
exit;
}
function reroute_session($base)
{
header("Location:http://$base?page=home");
exit;
}
?>
Navigation:
[Reply to this message]
|