2 // @title Session class
3 // @author Matt Todd <matt@matttoddphoto.com>
5 // @desc A session class for easily accessing and administering sessions (can
6 // transparently keep all session data in the database)
7 // @requires stdexception.php (StdException class)
9 include_once('stdexception.php');
12 // hash type constants
13 // define("AUTH_HASHTYPE_SHA", 2);
14 // define("AUTH_HASHTYPE_MD5", 5);
18 // protected variables
19 private $strSID; // the session ID
21 // retreive an instance of the Session object (not a singleton, more of a factory of sorts)
22 public static function retreive() {
27 public static function initialize() {
28 // session_id("thehub"); // must be unique
29 session_name("thehub");
32 public static function flush() {
33 session_write_close();
35 public static function destroy() {
36 $_SESSION = array(); // empty session
37 setcookie(session_name(), '', time()-42000, '/'); // destroys associated session cookie
38 unset($_COOKIE[session_name()]); // just in case
39 session_destroy(); // destroys the session
40 session_start(); // overwrite it, yeah!
45 public static function flash() {
46 if(empty($_SESSION['flash'])) {
49 $flash = $_SESSION['flash'];
50 $_SESSION['flash'] = null;
54 public static function continue_to($url) {
55 $_SESSION['continue_to'] = $url;
59 public function __set($name, $value) {
60 // setcookie($name, $value->username, (15 * 60), ".clayton.edu", "/");
61 $_SESSION[$name] = $value;
63 public function __get($name) {
64 return $_SESSION[$name];
68 public function __destruct() {
69 // possibly put some serialization code in here?
74 class SessionException
extends StdException
{