I have a class called "account" and its methods are the pages that the logged-in user can access, eg
Class account {
function info (){
//bla bla
}
function post () {
// bla bla
}
}
and for each method that the user is going to access, I have to make a conditional to check if the session is active, eg:
if($userLogged){
//deixar acessar
} else {
//redireciona
}
Is there any way to do a single check for all methods? something like a construct, for whatever method that was instantiated the verification would already be done and would try to give access or redirect the user.
UPDATE:
Is it safe to do a simple construct for this? ex:
function __construct() {
if (!$userLogged)
die('blabla');
}