Hi all, I'm trying to make this work with no luck.
I need user to login before using any page. so, at the top of the page I have this:
<?php require_once($_SERVER['DOCUMENT_ROOT'] . '/includes/initialise.inc.php'); ?>
initialise.inc.php starts as follows
<?php
//check if user is logged in, otherwise redirect to login page
session_start();
if (!isset($_SESSION['user'])) {
$host = $_SERVER['HTTP_HOST'];
$page = 'login.php';
$location = "Location: http://{$host}/{$page}";
header($location);
exit();
}
but as i said, this doesn't work.
$location gets equal to Location: http://localhost/login.php which is just fine if i copy and paste in the browser, but doesn't work in the redirect. Firefox says:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
what am I doing wrong?