Hi
BIG problem here that im struggeling for like 4 hours
i have 3 pages : index , teachers , classes and in all those 3 php pages i required core.php that has ob_start, session_start and two function , the loggedin function works perfectly BUT the loggedout on the other hand acting weird!
i tried to login in those 3 pages and when i login then switch between pages , session is destroyed automatically, doesn't matter if i login in index and go to classes or i login in teachers and go to index!
when i comment the loggedout part in core.php then i can stay logged in | someone give me gun |
core.php code
<?php
ob_start();
@session_start();
$current_file = $_SERVER['SCRIPT_NAME'];
@$http_referer =$_SERVER['HTTP_REFERER'];
function loggedin() {
if(isset($_SESSION['user_id'])&& !empty($_SESSION['user_id'])){
return true;
}else{
return false;
}
}
function loggedout(){
session_destroy();
}
?>
this part of the code is where i called the function and its the same in all those 3 pages
<?php if(loggedin()) { ?>
<li role="presentation"><a href="<?php loggedout(); ?>">Logout</a></li>
<?php } else { ?>
<li role="presentation"><a class="pop-up" href="#" data-val= '<?php include "libs/login.html"; ?>'>login</a></li>
<li role="presentation"><a class="pop-up" href="#" data-val= '<?php include "libs/register.html"; ?>'>register</a></li>
<?php } ?>
Thanks for anyhelp