Thursday, 5 September 2013

PHP if condition fails

PHP if condition fails

pI'll explain this in a bit detail, I've 2 pages, 1st codelogin.php/code
and 2nd codeconnection.php/code/p pOn codelogin.php/code /p
precoderequire_once('connection.php'); $_SESSION['logged_in'] = false;
/code/pre pIn codeconnection.php/code am having this condition/p
precodeif(basename($_SERVER['PHP_SELF']) !== 'login.php') { //If not
login.php if(!isset($_SESSION['logged_in'])) { //$_SESSION['logged_in'] =
false; print_r($_SESSION); //This shows array(); exit; //If I remove this
the below condition is satisfied and it redirects, why? }
if($_SESSION['logged_in'] !== true) { header('Location:'.base_url('r'));
exit; } } /code/pre pAs I've explained in my comments, codeprint_r()/code
shows codearray()/code and the moment I remove codeexit/code it redirects
the page to codebase_url()/code instead it should skip the codeif/code
condition as code$_SESSION['logged_id']/code is not even set./p pError
Reporting is on, P.S, I've also cleared codesession_id/code cookie and
requested the pages directly without going to codelogin.php/code which
sets code$_SESSION['logged_in'] = false;/code/p

No comments:

Post a Comment