Page 1 of 1

header() strange behaviour

Posted: Wed Sep 05, 2007 9:58 pm
by flycast
I am using header to redirect if certain cookies are not present. The code:

Code: Select all

function cookieCheck(){

//Check for robots and allow them to see the site
if (preg_match ( "/Google/", $_SERVER['HTTP_USER_AGENT'])){
	//It's a robot
	exit();
}

//Check for cookies first
if (!isset($_COOKIE['State']) and !isset($_SESSION['State'])){
	ini_set('session.use_trans_sid', true);
	$_SESSION['Page'] = $_SERVER['SCRIPT_NAME'];
	setcookie("Page", $_SERVER['SCRIPT_NAME'], time() + (60*60));
	header("Location: http://legacykc.janasnyder.com/entry?PHPSESSID=".session_id());
	exit();
}elseif (isset($_COOKIE['State'])){
	ini_set('session.use_trans_sid', false);
	$State = $_COOKIE['State'];
	setcookie("State", $State, time() + (60*60*24*365*2));
}
}//End of cookieCheck function
When the cookie is not present instead of redirecting to the page I get an Apache page that says:
Title: 200 OK
OK

The document has moved here.
Does anybody have experience with this? Why is Apache not going straight to my page?