You can use Session
to control whether the user is logged in or not, here's an example of how you could do this control.
PHP
class auth
{
public static function logged($url)
{
if(!$_SESSION['logged'])
header("location :".$url);
}
public static function login($username, $password)
{
if($username == "usuario" && $senha == "senha")
$_SESSION['logged'] = true;
else
return false;
return true;
}
public static function logout()
{
if($_SESSION['logged'])
unset($_SESSION['logged']);
}
}
And to make the control on your page do this.
PHP
auth::logged("/login");
You may be using this authentication class to mount the process and adapt to your system.