Page 1 of 1
Security on each page
Posted: Sun Aug 20, 2006 2:07 pm
by chrchcol
I have a login and validation page before someone can get into a simple web application I am writing.
Is there anything that I can include on each script page that requires them to have logged in before accessing it?
Does anyone have the best idea?
Chris
Posted: Sun Aug 20, 2006 2:17 pm
by daedalus__
You can include a script.
Posted: Sun Aug 20, 2006 2:30 pm
by PapiSolo
Wouldn't it be better to be a require() in this case? With include(), it will give an error and then continue but with require() it will halt all execution... right?
Posted: Sun Aug 20, 2006 2:35 pm
by Luke
PapiSolo wrote:Wouldn't it be better to be a require() in this case? With include(), it will give an error and then continue but with require() it will halt all execution... right?
yea that's right. I RARELY use include.
Posted: Sun Aug 20, 2006 6:42 pm
by griffinmt
More to the point, after a successfull login, set a SESSION variable to indicate who has just logged on.
then, as suggested, include a php file that has in it (among other things):
Code: Select all
<?PHP
session_start();
.
.
if (!isset($_SESSION['userid']))
{
// not logged in so go handle
}
else
{
// user is logged in so do the other stuff
}
?>