aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Web
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2019-01-30 18:34:44 -0800
committerzotlabs <mike@macgirvin.com>2019-01-30 18:34:44 -0800
commita56bc0e1e03aa6b369cf33fc4f4af49c55f3a276 (patch)
tree7b056227c860c3023532d80181e6c7a526bb0bd7 /Zotlabs/Web
parent519db2aacef0a0a4f107cd4d829993ed51771159 (diff)
parente64c5661da564426fa597e665451112177719aca (diff)
downloadvolse-hubzilla-a56bc0e1e03aa6b369cf33fc4f4af49c55f3a276.tar.gz
volse-hubzilla-a56bc0e1e03aa6b369cf33fc4f4af49c55f3a276.tar.bz2
volse-hubzilla-a56bc0e1e03aa6b369cf33fc4f4af49c55f3a276.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into xdev_merge
Diffstat (limited to 'Zotlabs/Web')
-rw-r--r--Zotlabs/Web/Session.php46
1 files changed, 34 insertions, 12 deletions
diff --git a/Zotlabs/Web/Session.php b/Zotlabs/Web/Session.php
index 4f2a3f1f7..fe0a3fbf9 100644
--- a/Zotlabs/Web/Session.php
+++ b/Zotlabs/Web/Session.php
@@ -15,7 +15,7 @@ class Session {
private $handler = null;
private $session_started = false;
-
+ private $custom_handler = false;
public function init() {
$gc_probability = 50;
@@ -23,25 +23,46 @@ class Session {
ini_set('session.gc_probability', $gc_probability);
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_httponly', 1);
-
+
+ $this->custom_handler = boolval(get_config('system', 'session_custom', false));
+
/*
* Set our session storage functions.
*/
+
+ if($this->custom_handler) {
+ /* Custom handler (files, memached, redis..) */
+
+ $session_save_handler = strval(get_config('system', 'session_save_handler', Null));
+ $session_save_path = strval(get_config('system', 'session_save_path', Null));
+ $session_gc_probability = intval(get_config('system', 'session_gc_probability', 1));
+ $session_gc_divisor = intval(get_config('system', 'session_gc_divisor', 100));
+ if(!$session_save_handler || !$session_save_path) {
+ logger('Session save handler or path not set.',LOGGER_NORMAL,LOG_ERR);
+ }
+ else {
+ ini_set('session.save_handler', $session_save_handler);
+ ini_set('session.save_path', $session_save_path);
+ ini_set('session.gc_probability', $session_gc_probability);
+ ini_set('session.gc_divisor', $session_gc_divisor);
+ }
+ }
+ else {
+ $handler = new \Zotlabs\Web\SessionHandler();
- $handler = new \Zotlabs\Web\SessionHandler();
-
- $this->handler = $handler;
+ $this->handler = $handler;
- $x = session_set_save_handler($handler,false);
- if(! $x)
- logger('Session save handler initialisation failed.',LOGGER_NORMAL,LOG_ERR);
+ $x = session_set_save_handler($handler,false);
+ if(! $x)
+ logger('Session save handler initialisation failed.',LOGGER_NORMAL,LOG_ERR);
+ }
// Force cookies to be secure (https only) if this site is SSL enabled.
// Must be done before session_start().
$arr = session_get_cookie_params();
-
+
// Note when setting cookies: set the domain to false which creates a single domain
// cookie. If you use a hostname it will create a .domain.com wildcard which will
// have some nasty side effects if you have any other subdomains running hubzilla.
@@ -86,14 +107,15 @@ class Session {
$arr = session_get_cookie_params();
- if($this->handler && $this->session_started) {
+ if(($this->handler || $this->custom_handler) && $this->session_started) {
session_regenerate_id(true);
// force SessionHandler record creation with the new session_id
// which occurs as a side effect of read()
-
- $this->handler->read(session_id());
+ if (! $this->custom_handler) {
+ $this->handler->read(session_id());
+ }
}
else
logger('no session handler');