diff options
author | Simon Rettberg | 2022-07-01 17:48:55 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-07-01 17:48:55 +0200 |
commit | 8d6ddbbd0714c90651cba2a955df6aa99fc1143f (patch) | |
tree | 285bac7aba6bf67dfcd6b9c601738d2531b72a67 /inc | |
parent | [dnbd3] Rename/refactor RPC methods/constants (diff) | |
download | slx-admin-8d6ddbbd0714c90651cba2a955df6aa99fc1143f.tar.gz slx-admin-8d6ddbbd0714c90651cba2a955df6aa99fc1143f.tar.xz slx-admin-8d6ddbbd0714c90651cba2a955df6aa99fc1143f.zip |
[inc/Session] Add call to save session data
Diffstat (limited to 'inc')
-rw-r--r-- | inc/session.inc.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/inc/session.inc.php b/inc/session.inc.php index 3afbc4ce..d83de088 100644 --- a/inc/session.inc.php +++ b/inc/session.inc.php @@ -152,11 +152,11 @@ class Session ErrorHandler::traceError('Error: Could not set Cookie for Client (headers already sent)'); } register_shutdown_function(function () { - Session::saveInternal(); + self::saveOnShutdown(); }); } - - public static function saveInternal() + + private static function saveOnShutdown() { $now = time(); $args = ['lastip' => $_SERVER['REMOTE_ADDR']]; @@ -166,6 +166,19 @@ class Session if (self::$dataChanged) { $args['data'] = json_encode(self::$data); } + self::saveData($args); + } + + public static function saveExtraData() + { + if (!self::$dataChanged) + return; + self::saveData(['data' => json_encode(self::$data)]); + self::$dataChanged = false; + } + + private static function saveData(array $args) + { $query = "UPDATE session SET " . implode(', ', array_map(function ($key) { return "$key = :$key"; }, array_keys($args))) . " WHERE sid = :sid"; |