From 21fedb3af692b12c1f0aa266bbf788b01f2cbe4c Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sun, 26 Mar 2023 04:50:46 +0300 Subject: auth tests --- core/classes/session/FilesSession.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'core/classes/session/FilesSession.php') diff --git a/core/classes/session/FilesSession.php b/core/classes/session/FilesSession.php index 8762776..a06f29c 100644 --- a/core/classes/session/FilesSession.php +++ b/core/classes/session/FilesSession.php @@ -35,6 +35,7 @@ class FileSessionHandler implements SessionHandlerInterface public function __construct() { // values comming from configuration + $this->sessionName = SESSION_NAME; $this->sess_filename = $path; $this->minutes = $minutes; @@ -49,7 +50,7 @@ class FileSessionHandler implements SessionHandlerInterface ); // Start the session - session_name(SESSION_NAME); + session_name($this->sessionName); session_start(); } @@ -80,14 +81,9 @@ class FileSessionHandler implements SessionHandlerInterface public function read($sessionId): string|false { if (!file_exists($filename) || !is_readable($filename)) return false; - return file_get_contents($filename); + $data = file_get_contents($filename); - # if ($this->files->isFile($path = $this->path.'/'.$sessionId) && - # $this->files->lastModified($path) >= Carbon::now()->subMinutes($this->minutes)->getTimestamp()) { - # return $this->files->sharedGet($path); - # } - - # depricated? return ''; + return @unserialize($data); } /** write @@ -96,11 +92,11 @@ class FileSessionHandler implements SessionHandlerInterface public function write($sessionId, $data): bool { $h = fopen($filename, 'w'); - if (fwrite($h,$data) === false) { + if (fwrite($h, serialize($data)) === false) { throw new Exception('Could not write session data'); return false; - } - fclose($h); + } + fclose($h); return true; } @@ -128,7 +124,7 @@ class FileSessionHandler implements SessionHandlerInterface ->in($this->path) ->files() ->ignoreDotFiles(true) - ->date('<= now - '.$lifetime.' seconds'); + ->date('<= now - '. $lifetime .' seconds'); $deletedSessions = 0; -- cgit v1.2.3