You say that you use session_start in your script... I just want to clarify, since you're missing it in admin.php.
Also, your admin.php seems quirky: when $_SESSION['granted'] is NOT equal to "yes", you're redirected back to admin.php, not index.php... Is this a typo in your post, or a bug in your actual code?
A complete working version follows:
<?php // index.php
if (isset($_GET['do_enter']) && ($_GET['do_enter'] != ''))
{
session.start()
$_SESSION['granted'] = 'yes';
header('Location: admin.php');
exit;
}
else
{
// do something else
}
?>
<?php // admin.php
session_start();
if ($_SESSION['granted'] !== 'yes')
{
header("Location: index.php");
exit;
}
else
{
//whatever I want to do on this page
}
?>
To enter the admin site, just append "?do_enter=true" to the URL after index.php.
Take care,
Nik
http://www.bigaction.org/