Hello everyone.
I am brushing up php, and i was working at a simple login logout system.
Now the thing is that it doesn't log me out!
index.php
<?php
require 'core.inc.php';
require 'connect.inc.php';
if(loggedin){
echo 'You are logged in and you session id is '.$_SESSION['user_id'].'<a href="logout.php">Log Out</a>';
}else{
include 'loginform.inc.php';
}
}
core.inc.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;
}
}
If i do the ' if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])' in the index.php rather than do that in a function, it works perfectly, logs me out and it shows me the loginform.php again. If it is in a function that I call, it doesn't work.
Could someone please help me out and tell me why is that?
It just seems weird, especially because I am following a video tutorial and i am doing things like the guy in the video does.
Appreciate your help.
Manuel


Reply With Quote
Bookmarks