OK, I would do exactly what you are saying. To set the session, you should probably use:
$logged = true;
session_register("logged");
on the top of every page, use this:
session_start();
if( ! isset($_SESSION['logged'])) {
header(....redirect to logon page);
}
to clear the session data, use:
unset($_SESSION['logged']);
session_destroy();