How to bypass an HTTP redirect?

Asked

Viewed 202 times

3

Is there any way to do a "bypass" and access the page? For example:

if(!isset($variavel)) { 
  header ('Location: error.php');
} else {
  echo 'oi';
}

1 answer

3

I don’t know if you consider it a bypass, but header issuance does not finish the script. You should do this manually with exit after a redirect, or the script moves on:

if(!isset($variavel)) { 
  header ('Location: error.php');
  exit;
} else {
  echo 'oi';
}
// Chegaria aqui sem o exit

If your doubt is about the execution of else of your code, this is unrelated to the redirect. It all depends on the variable $variavel be defined or not. Of course, if the redirect code of your example is executed, there is no else also be executed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.