X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FSession.php;h=d9143c8809e1b1b8df215238fd3cd3585e24ffe8;hb=4facd1dfdba93ede48ca40b5e146424e6701118b;hp=b245c675b0f0981f7d0a759e2fbb2cb5ac4065de;hpb=7acb4b04343df31c2cc78214fae5429c66d95fb2;p=friendica.git diff --git a/src/Core/Session.php b/src/Core/Session.php index b245c675b0..d9143c8809 100644 --- a/src/Core/Session.php +++ b/src/Core/Session.php @@ -11,7 +11,7 @@ use Friendica\Core\Session\DatabaseSessionHandler; /** * High-level Session service class * - * @author Hypolite Petovan + * @author Hypolite Petovan */ class Session { @@ -45,9 +45,24 @@ class Session return isset($_SESSION[$name]); } - public static function get($name) + /** + * Retrieves a key from the session super global or the defaults if the key is missing or the value is falsy. + * + * Handle the case where session_start() hasn't been called and the super global isn't available. + * + * @param string $name + * @param mixed $defaults + * @return mixed + */ + public static function get($name, $defaults = null) { - return defaults($_SESSION, $name, null); + if (isset($_SESSION)) { + $return = defaults($_SESSION, $name, $defaults); + } else { + $return = $defaults; + } + + return $return; } public static function set($name, $value)