Get方法中未定义的会话变量

Hi i'm trying to get the value in session in my get method,actually value is there but its throwing an error that undefined $_SESSION variable as i'm returning value in this get method,so code is not executing furher.Please help1

<?php

class Session {

    public static function init() {
        session_start();
    }

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

    public static function get($key) {
        return $_SESSSION[$key];
    }

    public static function destroy() {
        //unset($_SESSION);
        session_destroy();
    }

}?>

You haven't spelt SESSION correctly in your get function you have SESSSION .

class Session {

public static function init() {
    session_start();
}

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

public static function get($key) {
    return $_SESSION[$key];
}

public static function destroy() {
    //unset($_SESSION);
    session_destroy();
}

}

Maybe use a test to see if the key exists before trying to return a non-existent value? Like this perhaps?

public static function get($key) {
    return array_key_exists( $key, $_SESSION ) ? $_SESSION[ $key ] : false;
}