<?php
class Session {

	# Singleton
	static $instance = null;

	static function getInstance() {
		if ( self::$instance == null ) {
			self::$instance = new Session();
		}
		return self::$instance;
	}
	
    function __construct(){
    	// Starte PHP-Session-Verwaltung
		session_start();
    }
    
    static function start() {
    	self::getInstance();
    }
	
    function set( $key, $value ) {
    	$_SESSION[$key] = $value;
    }

    function get( $key, $default=null ) {
        if (isset($_SESSION[$key])) return $_SESSION[$key];
        if (isset($default)) return $default;
		throw new Exception("Schlüssel $key existiert nicht in Session");
    }
}

?>