Merge pull request #5563 from MrPetovan/bug/5470-fix-various-notices

Fix various notices
This commit is contained in:
Michael Vogel
2018-08-07 21:34:47 +02:00
committed by GitHub
6 changed files with 37 additions and 27 deletions

View File

@@ -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)