& Amp; lt ;? Php {code...}. What is the difference between php {code...} and above code that implements redirection with the header?
session_start();if(isset($_SESSION['userId'],$_SESSION['name'],$_SESSION['rights'])){ echo "
";}else{ echo "
";}
In the above Code, what is the difference between this jump and the header implementation?
Reply content:
session_start();if(isset($_SESSION['userId'],$_SESSION['name'],$_SESSION['rights'])){ echo "
";}else{ echo "
";}
In the above Code, what is the difference between this jump and the header implementation?
The difference is:
Meta redirect can be applied to situations where http headers have been sent out. For example, if a webpage has already been rendered in half, it has to be redirected. Another advantage is that it can be delayed.
Header redirect is used to redirect http headers before they are sent. For example, when a webpage is opened and not rendered, it is redirected.header("Location: url", $status_code)
. You can also add status code and the former will not work.
I prefer headers and use meta redirect. Occasionally, the jump fails, and the header redirect can be added with status_code, which is better for seo.
Like your code, use the header.session_start();
The call can be successful only when http headers has not been sent.
If meta redirect is required, we recommend that you addexit;
Think about it, one is on the server, and the other is on the browser. It's not good .....:[