Page 1 of 1

is there any problem replacing this way

Posted: Wed Sep 24, 2008 6:13 am
by rami
ok just for the moment forgeting session hijacking factor....
suppose i do like this to check if user is logged in every page
if (!isset($_SESSION['name']) && !isset($_SESSION['level'])) {
do task in normal page give for to edit/delete if it is thier page using id on session
}
else
{
}

now rather writing code in each page if i replace it with function in fuctions.php
and do
function checklogin()
{
if (!isset($_SESSION['id']) && !isset($_SESSION['level'])) {
$var=1;
}
else
{
$var=0
}
return $var;


and now if i do
include functions
$logging=0;
$logging=checklogin();
if ($logging==1)
{
do task
}
else
{
donot do
}

so are there any problems?
how secure is it..?
any suggestion and modification.....
if global registers are on what can be problems..in this...

Re: is there any problem replacing this way

Posted: Wed Sep 24, 2008 11:17 am
by Christopher
They are the same, but I think your check logic is backwards.

Re: is there any problem replacing this way

Posted: Wed Sep 24, 2008 9:47 pm
by rami
backwards in what way ..you mean old

how can i upgrade it or make it better...
any suggestion and help

thanks

Re: is there any problem replacing this way

Posted: Thu Sep 25, 2008 12:12 am
by Christopher

Code: Select all

function isLoggedIn() {
    return isset($_SESSION['id']) && isset($_SESSION['level']);
}

Re: is there any problem replacing this way

Posted: Thu Sep 25, 2008 5:27 am
by rami
thanks
now i am doing directly this
if (isLoggedIn())
{
}
else
{

}

i think there is no problem doing it .Inst it?

can some body expand that login check function to make it even safer ....

thanks

Re: is there any problem replacing this way

Posted: Mon Sep 29, 2008 1:15 pm
by kaisellgren
How about you start using code tags, even better would be if you use PHP code tags.

Code: Select all


;)