|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
class SiteSessionHandler implements SessionHandlerInterface {
|
|
class SiteSessionHandler implements SessionHandlerInterface {
|
|
|
|
|
|
|
|
- public function open($path, $name) {
|
|
|
|
|
|
|
+ public function open($path, $name): bool {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -11,9 +11,9 @@ class SiteSessionHandler implements SessionHandlerInterface {
|
|
|
* @return string
|
|
* @return string
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
- public function read($id) {
|
|
|
|
|
|
|
+ public function read($id): string {
|
|
|
$session = Session::get($id);
|
|
$session = Session::get($id);
|
|
|
- return $session ? $session->data : "";
|
|
|
|
|
|
|
+ return $session->data ?? "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -22,8 +22,7 @@ class SiteSessionHandler implements SessionHandlerInterface {
|
|
|
* @return bool
|
|
* @return bool
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
- public function write($id, $data) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ public function write($id, $data): bool {
|
|
|
$session = Session::get($id);
|
|
$session = Session::get($id);
|
|
|
if(!$session) {
|
|
if(!$session) {
|
|
|
$session = new Session;
|
|
$session = new Session;
|
|
@@ -35,7 +34,7 @@ class SiteSessionHandler implements SessionHandlerInterface {
|
|
|
return $session->commit();
|
|
return $session->commit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function close() {
|
|
|
|
|
|
|
+ public function close(): bool {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -44,25 +43,24 @@ class SiteSessionHandler implements SessionHandlerInterface {
|
|
|
* @return bool
|
|
* @return bool
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
- public function destroy($id) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ public function destroy($id): bool {
|
|
|
$session = Session::get($id);
|
|
$session = Session::get($id);
|
|
|
if($session) $session->delete();
|
|
if($session) $session->delete();
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @param int $lifetime
|
|
|
|
|
- * @return bool
|
|
|
|
|
|
|
+ * @param int $max_lifetime
|
|
|
|
|
+ * @return int
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
- public function gc($lifetime) {
|
|
|
|
|
- $threshold = time() - $lifetime;
|
|
|
|
|
|
|
+ public function gc($max_lifetime): int {
|
|
|
|
|
+ $threshold = time() - $max_lifetime;
|
|
|
$date_time = gmdate("Y-m-d H:i:s", $threshold);
|
|
$date_time = gmdate("Y-m-d H:i:s", $threshold);
|
|
|
|
|
|
|
|
$sql = "DELETE FROM `session` WHERE `dts_last_access` < '$date_time'";
|
|
$sql = "DELETE FROM `session` WHERE `dts_last_access` < '$date_time'";
|
|
|
- $result = db::query($sql);
|
|
|
|
|
- return !empty($result);
|
|
|
|
|
|
|
+ db::query($sql);
|
|
|
|
|
+ return db::affectedRows();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|