Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions lib/Horde/SessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,29 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package SessionHandler
*/
class Horde_SessionHandler
class Horde_SessionHandler implements SessionHandlerInterface
{
/**
* The session data.
*
* @var string
*/
public $data = '';

/**
* The session identifier.
*
* @var string
*/
public $id = '';

/**
* The session name.
*
* @var string
*/
public $name = '';

/**
* If true, indicates the session data has changed.
*
Expand Down Expand Up @@ -92,14 +113,7 @@ public function __construct(Horde_SessionHandler_Storage $storage,
$this->_storage = $storage;

if (empty($this->_params['noset'])) {
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
session_set_save_handler($this);
}
}

Expand All @@ -122,7 +136,7 @@ public function __destruct()
*
* @return boolean True on success, false otherwise.
*/
public function open($save_path = null, $session_name = null)
public function open($save_path = null, $session_name = null): bool
{
if (!$this->_connected) {
try {
Expand All @@ -143,7 +157,7 @@ public function open($save_path = null, $session_name = null)
*
* @return boolean True on success, false otherwise.
*/
public function close()
public function close(): bool
{
try {
$this->_storage->close();
Expand All @@ -164,7 +178,7 @@ public function close()
*
* @return string The session data.
*/
public function read($id)
public function read($id): string|false
{
if (($result = $this->_storage->read($id)) == '') {
$this->_logger->log('Error retrieving session data (' . $id . ')', 'DEBUG');
Expand All @@ -189,7 +203,7 @@ public function read($id)
*
* @return boolean True on success, false otherwise.
*/
public function write($id, $session_data)
public function write($id, $session_data): bool
{
if ($this->changed ||
(empty($this->_params['no_md5']) &&
Expand All @@ -213,7 +227,7 @@ public function write($id, $session_data)
*
* @return boolean True on success, false otherwise.
*/
public function destroy($id)
public function destroy($id): bool
{
if ($this->_storage->destroy($id)) {
$this->_logger->log('Session data destroyed (' . $id . ')', 'DEBUG');
Expand All @@ -233,7 +247,7 @@ public function destroy($id)
*
* @return boolean True on success, false otherwise.
*/
public function gc($maxlifetime = 300)
public function gc($maxlifetime = 300): int|false
{
return $this->_storage->gc($maxlifetime);
}
Expand Down
Loading