* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team * */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Web\Session; /** * Base class for handling sessions */ abstract class Session extends SessionNamespace { /** * Container for session namespaces * * @var array */ protected $namespaces = array(); /** * Read all values from the underlying session implementation */ abstract public function read(); /** * Persists changes to the underlying session implementation */ abstract public function write(); /** * Purge session */ abstract public function purge(); /** * Assign a new session id to this session. */ abstract public function refreshId(); /** * Get or create a new session namespace * * @param string $identifier The namespace's identifier * * @return SessionNamespace */ public function getNamespace($identifier) { if (!isset($this->namespaces[$identifier])) { $this->namespaces[$identifier] = new SessionNamespace(); } return $this->namespaces[$identifier]; } /** * Return whether the given session namespace exists * * @param string $identifier The namespace's identifier to check * * @return bool */ public function hasNamespace($identifier) { return isset($this->namespaces[$identifier]); } /** * Remove the given session namespace * * @param string $identifier The identifier of the namespace to remove */ public function removeNamespace($identifier) { unset($this->namespaces[$identifier]); } /** * Clear all values and namespaces from the session cache */ public function clear() { $this->values = array(); $this->namespaces = array(); } }