public static function destroy($key = '', $prefix = false)
    {
        if (self::$sessionStarted == true) {
            if ($key == '' && $prefix == false) {
                session_unset();
                session_destroy();
            } elseif ($prefix == true) {
                foreach ($_SESSION as $index => $value) {
                    if (strpos($index, self::$prefix) === 0) {
                        unset($_SESSION[$index]);
                    }
                }
            } else {
                unset($_SESSION[self::$prefix . $key]);
            }

            return true;
        }

        return false;
    }
public static function destroy($key = '', $prefix = false)
    {
        if (self::$sessionStarted == true) {
            if ($key == '' && $prefix == false) {
                session_unset();
                session_destroy();
            } elseif ($prefix == true) {
                foreach ($_SESSION as $index => $value) {
                    if (strpos($index, self::$prefix) === 0) {
                        unset($_SESSION[$index]);
                    }
                }
            } else {
                unset($_SESSION[self::$prefix . $key]);
            }

            return true;
        }

        return false;
    }
public static function destroy ( $ key = '' , $ prefix = false ) { if ( self :: $ sessionStarted == true ) { if ( $ key == '' && $ prefix == false ) { session_unset ( ) ; session_destroy ( ) ; } elseif ( $ prefix == true ) { foreach ( $ _SESSION as $ index => $ value ) { if ( strpos ( $ index , self :: $ prefix ) === 0 ) { unset ( $ _SESSION [ $ index ] ) ; } } } else { unset ( $ _SESSION [ self :: $ prefix . $ key ] ) ; } return true ; } return false ; }
Empties and destroys the session.

@param string $key    → session name to destroy
@param bool   $prefix → if true clear all sessions for current prefix

@return bool
Empties and destroys the session .