I place the following at the top of every page on my site.
require_once "classes/Session.php";
This class:
require_once 'Form.php';
require_once 'Database.php';
class Session{
public $referrer;
public $logged_in;
public $url;
public function __construct(){
$this->startSession();
}
public function startSession(){
session_start();
$this->logged_in = $this->checkLogin();
//set last page visited
if(isset($_SESSION['url'])){
$this->referrer = $_SESSION['url'];
}
else{
$this->referrer = "/";
}
//sets the current URL
$this->url = $_SESSION['url'] = $_SERVER['REQUEST_URI'];
}
}
I've changed my approach to how I handle this.
I used to put new Session at the bottom of Session.php but that isn't pure OOP?
What I don't understand is where to create the Session object so I can use it on my page?
I'm a bit confused about this but feel I'm missing something basic to just get me thinking on the right lines.
Any help would be great!