]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Session/Handler/Database.php
Reverted some changes that won't work with PHP7.3
[friendica.git] / src / Core / Session / Handler / Database.php
index 714471f9fe7cd628158f804409a56831c641d959..41ccb6b33f834e4f315fef4b6b78a5f2813bebff 100644 (file)
 
 namespace Friendica\Core\Session\Handler;
 
-use Friendica\Core\Session;
 use Friendica\Database\Database as DBA;
 use Psr\Log\LoggerInterface;
-use SessionHandlerInterface;
 
 /**
  * SessionHandler using database
  */
-class Database implements SessionHandlerInterface
+class Database extends AbstractSessionHandler
 {
        /** @var DBA */
        private $dba;
@@ -37,6 +35,8 @@ class Database implements SessionHandlerInterface
        private $logger;
        /** @var array The $_SERVER variable */
        private $server;
+       /** @var bool global check, if the current Session exists */
+       private $sessionExists = false;
 
        /**
         * DatabaseSessionHandler constructor.
@@ -66,7 +66,7 @@ class Database implements SessionHandlerInterface
                try {
                        $session = $this->dba->selectFirst('session', ['data'], ['sid' => $id]);
                        if ($this->dba->isResult($session)) {
-                               Session::$exists = true;
+                               $this->sessionExists = true;
                                return $session['data'];
                        }
                } catch (\Exception $exception) {
@@ -101,11 +101,11 @@ class Database implements SessionHandlerInterface
                        return $this->destroy($id);
                }
 
-               $expire         = time() + Session::$expire;
+               $expire         = time() + static::EXPIRE;
                $default_expire = time() + 300;
 
                try {
-                       if (Session::$exists) {
+                       if ($this->sessionExists) {
                                $fields    = ['data' => $data, 'expire' => $expire];
                                $condition = ["`sid` = ? AND (`data` != ? OR `expire` != ?)", $id, $data, $expire];
                                $this->dba->update('session', $fields, $condition);