Hi,
I'm trying to check if a user is logged in from within each page... I want to just call a function, so that I don't have duplicate code on every page.... So I tried this:
On each page:
session_start();
check_login();
On included scripts page:
function check_login(){
// if not logged in, redirect to login page
if(!$_SESSION["logged_in"]){
header("Location: login.php");
exit;
}
}
...But, I get an error message saying "Cannot modify header information - header already created" or something like that... So, I was wondering, is there any other way to do the whole redirecting thing without using header? Or, just any other way that it can be possible that I can have it in a function. I guess my question is, what is the norm?
Thanks,
Heather