Commit 2d0c3c79 authored by Donal McMullan's avatar Donal McMullan

Change session object to be a singleton

parent c6e39e4c
......@@ -79,13 +79,31 @@ class Session {
/**
* Resumes an existing session, only if there is one
*/
public function __construct() {
private function __construct() {
// Resume an existing session if required
if (isset($_COOKIE[session_name()])) {
session_start();
}
}
/**
* Singelton function keeps us from generating multiple instances of this
* class
*
* @return object The class instance
* @access public
*/
public static function singleton() {
//single instance
static $instance;
//if we don't have the single instance, create one
if(!isset($instance)) {
$instance = new Session();
}
return($instance);
}
/**
* Gets the session property keyed by $key.
*
......@@ -201,6 +219,16 @@ class Session {
}
}
/**
* Find out if the session has been started yet
*/
public function is_live() {
if ("" == session_id()) {
return false;
}
return true;
}
/**
* Escape a message for HTML output
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment