I'm coding a function to check the user if he logged in or he's a visitor to call it from the other files here is it :
function login_check(){
session_start();
if (!isset($_SESSION['logged']) && $_SESSION['logged'] == 'true') {
require_once('libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'libs/templates';
$smarty->compile_dir = 'libs/templates_c';
$smarty->config_dir = 'libs/configs';
$smarty->cache_dir = 'libs/cache';
$smarty->display('login.tpl');
die();
}}
So I added this line :
if (isset($_SESSION['logged']))
The problem is gone but the script is not working 🙁
Any ideas ?
The current full code is :
function login_check(){
session_start();
if (isset($_SESSION['logged']))
if (!isset($_SESSION['logged']) && $_SESSION['logged'] == 'true') {
require_once('libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = 'libs/templates';
$smarty->compile_dir = 'libs/templates_c';
$smarty->config_dir = 'libs/configs';
$smarty->cache_dir = 'libs/cache';
$smarty->display('login.tpl');
die();
}}