4 * @file src/Core/Session.php
6 namespace Friendica\Core;
8 use Friendica\Core\Session\CacheSessionHandler;
9 use Friendica\Core\Session\DatabaseSessionHandler;
12 * High-level Session service class
14 * @author Hypolite Petovan <mrpetovan@gmail.com>
18 public static $exists = false;
19 public static $expire = 180000;
21 public static function init()
23 ini_set('session.gc_probability', 50);
24 ini_set('session.use_only_cookies', 1);
25 ini_set('session.cookie_httponly', 1);
27 if (Config::get('system', 'ssl_policy') == SSL_POLICY_FULL) {
28 ini_set('session.cookie_secure', 1);
31 $session_handler = Config::get('system', 'session_handler', 'database');
32 if ($session_handler != 'native') {
33 if ($session_handler == 'cache' && Config::get('system', 'cache_driver', 'database') != 'database') {
34 $SessionHandler = new CacheSessionHandler();
36 $SessionHandler = new DatabaseSessionHandler();
39 session_set_save_handler($SessionHandler);
43 public static function exists($name)
45 return isset($_SESSION[$name]);
48 public static function get($name)
50 return defaults($_SESSION, $name, null);
53 public static function set($name, $value)
55 $_SESSION[$name] = $value;