I am using a location()
function call in my configuration file, but it keeps redirecting me to the page I am making to go to in the call to it,
I am doing this:
if (!isset($_SESSION['user_login_name']) || !isset($_SESSION['user_logged_in']))
{
header("Location: /login/");
exit();
}
What is the best way to make it so the server knows that it on the login page and not redirect back to this infinitely?
I think that the best way to do this would be to have a $_SERVER
check to see if the current script is in the /login/
directory, this could be as follows:
if (!isset($_SESSION['user_login_name']) || !isset($_SESSION['user_logged_in']))
{
if ($_SERVER['SCRIPT_NAME'] !== '/login/index.php')
{
header("Location: /login/");
exit();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.