To password protect or check if user loged in from another PHP script, check for session variable "USERNAME". Sample code is below.


Code:
<?php

require("/path/to/include/config.php");

if (!isset($_SESSION['USERNAME'])) {
    Header("Location: {$config['baseurl']}/login.php");
        exit(0);
}

?>

<html>
<body>
<h1>Welcome to Members Area</h1>
</body>
</html>

HOWTO