X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FSession.php;h=d9143c8809e1b1b8df215238fd3cd3585e24ffe8;hb=2a881cc2e71b1677cc9ce98001ae3f157743e542;hp=20d1e9ef7b521e6aac48cce6e357a2633078eadb;hpb=25fbdd21c5a4bbf38c52f9275c126e9ef687b61d;p=friendica.git diff --git a/src/Core/Session.php b/src/Core/Session.php index 20d1e9ef7b..d9143c8809 100644 --- a/src/Core/Session.php +++ b/src/Core/Session.php @@ -5,13 +5,13 @@ */ namespace Friendica\Core; +use Friendica\Core\Session\CacheSessionHandler; use Friendica\Core\Session\DatabaseSessionHandler; -use Friendica\Core\Session\MemcacheSessionHandler; /** * High-level Session service class * - * @author Hypolite Petovan + * @author Hypolite Petovan */ class Session { @@ -28,10 +28,10 @@ class Session ini_set('session.cookie_secure', 1); } - if (!Config::get('system', 'disable_database_session')) { - $memcache = Cache::memcache(); - if (is_object($memcache)) { - $SessionHandler = new MemcacheSessionHandler($memcache); + $session_handler = Config::get('system', 'session_handler', 'database'); + if ($session_handler != 'native') { + if ($session_handler == 'cache' && Config::get('system', 'cache_driver', 'database') != 'database') { + $SessionHandler = new CacheSessionHandler(); } else { $SessionHandler = new DatabaseSessionHandler(); } @@ -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)