The way I do it is by using sessions. Put session_start(); at the top of each page, and when the user logs in, you register a session variable, like this:
$_SESSION['user'] = $username;
Then you can validate a user like this:
if(isset($_SESSION['user']))
{
echo "Logged in...";
}
else
{
echo "Not logged in...";
}