when i try include with ../ at that time this error showing me.
Warning: session_destroy(): Trying to destroy uninitialized session in D:\xampp\htdocs\PHP\MyBlog\lib\Session.php on line 27
Admin login file location MyBlog/admin/inc/header.php
<?php
include '../lib/Session.php';
Session::checkSession();
if (isset($_GET['action']) && $_GET['action'] == "logout"){
Session::destroy();
}
?>
<li><a href="?action=logout">Logout</a></li>
My Session File location MyBlog/lib/Session.php
<?php
class Session{
public static function init(){
session_start();
}
public static function set($key, $val){
$_SESSION['$key'] = $val;
}
public static function get($key){
if(isset($_SESSION['$key'])){
return $_SESSION['$key'];
} else{
return false;
}
}
public static function checkSession(){
self::init();
if(self::get("login")==false){
self::destroy();
header("Locaton:login.php");
}
}
public static function destroy(){
session_destroy();
header("Locaton:login.php");
}
}
?>
Then i also try this :
<?php
// include ($_SERVER['DOCUMENT_ROOT'].'/lib/Session.php');
//include "../../lib/Session.php";
include "/lib/Session.php";
Session::checkSession();
?>
Then its showing this kind of error: Warning: include(/lib/Session.php): failed to open stream: No such file or directory in D:\xampp\htdocs\PHP\MyBlog\admin\inc\header.php on line 4