<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/


class AHDB_Utils_Session {

    protected static $sessionInitialized = false;

    public static function start() {
        if ( false === self::$sessionInitialized ) {
            session_start();
            self::$sessionInitialized = true;
        }
    }

    public static function getId() {
        return session_id();
    }

    public static function set( $key, $value ) {
        $_SESSION[ $key ] = $value;
    }

    public static function get( $key ) {
        if ( isset( $_SESSION[ $key ] ) ) {
            return $_SESSION[ $key ];
        } else {
            return NULL;
        }
    }

    public static function destory() {
        if ( true === self::$sessionInitialized ) {
            session_unset();
            session_destroy();
        }
    }
} 