I'm trying to use redirection to secure certain pages on my site. The
theory is to check to see if a user is "logged in" at the top of a
page, and if not, redirect them to a login page.
A typical web page will look like this:
<!--#include virtual="secure.php"-->
<html>
<body>
<p>Secure Content Here</p>
</body>
</html>
The secure.php file looks like this:
<?
session_start();
$schema = $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http';
// Check to see if the user is logged in.
if (! isset($_SESSION["userid"]))
{
header("Location: " . $schema .
exit();
}
?>
This all works fine in ASP. In PHP, however, I can't seem to get the
redirect to work. If I just type the secure.php URL directly into the
browser's address bar, it will redirect properly. If I call the page
I want to secure (either with a .html or a .php extension), it just
seems to ignore the redirect.
Any idea why?