Source
xxxxxxxxxx
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Session wrapper uses cookie for session store.
*/
class CCookieSession implements SessionHandlerInterface {
/**
* Cookie name.
*/
public const COOKIE_NAME = ZBX_SESSION_NAME;
/**
* Cookie lifetime.
*/
public $lifetime = 0;
/**
* Class constructor. Set session handlers and start session.
*/
public function __construct() {
// Set use standard cookie PHPSESSID to false.
ini_set('session.use_cookies', '0');
session_set_save_handler($this, true);
}
/**
* @inheritDoc
*
* @return boolean
*/
public function close(): bool {
echo ob_get_clean();
return true;
}
/**
* @inheritDoc
*
* @param string $id
*
* @return boolean
*/
public function destroy($id): bool {
return CCookieHelper::unset(self::COOKIE_NAME);
}
/**
* @inheritDoc
*
* @param integer $maxlifetime
*
* @return integer
*/
#[\ReturnTypeWillChange]
public function gc($maxlifetime) {
return true;
}
/**
* @inheritDoc
*
* @param string $path
* @param string $name
*
* @return boolean
*/
public function open($path, $name): bool {
ob_start();
return session_status() === PHP_SESSION_ACTIVE;
}
/**
* @inheritDoc