Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

header(); presents infinite loop in IE, works on other browsers?

$
0
0

OK, I'll keep this short n sweet.

 

Goal:

 

If a specific variable is declared in the URL, assign it to a session and refresh the page without the variable. Here's my code:

 

if(isset($_SESSION['referrer'])){
	$referrer = $_SESSION['referrer'];
}else{
	if(isset($_REQUEST['referrer'])){
		$referrer = $_REQUEST['referrer'];
	}else{		
		$referrer = $no_referrer;
	}
}
				
$_SESSION['referrer'] = $referrer;
				
if(isset($_REQUEST['referrer'])){
	header("Refresh:0, url=/");
}

Expected result:

 

If the url http://testsite.com?referrer=abc123 is entered, check for existing session. If it doesn't exist, create one from $_REQUEST['referrer']. Then, check if $_REQUEST['referrer'] exists. If it does, immediately go to the root of the domain (this is located at the root of the domain) so that the url displayed is http://testsite.com instead of the ugly referrer showing.

 

Actual Result:

 

Works great on Chrome, Firefox, Safari, Opera, and Android 4.2.2's web browser, however in IE 8 through IE 11, that code presents an infinite header(); loop. It's executing the header("Refresh:0, url=/"); regardless of whether $_REQUEST['referrer'] is set or not


Viewing all articles
Browse latest Browse all 13200

Trending Articles