HEX
Server: Apache
System: Linux server1.ariadata.co 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: nepi (1051)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,show_source,popen,proc_open
Upload Files
File: /home/nepi/public_html/src/core/Directus/Session/Storage/ArraySessionStorage.php
<?php

namespace Directus\Session\Storage;

class ArraySessionStorage implements SessionStorageInterface
{
    /**
     * Session Name
     *
     * @var string
     */
    protected $sessionName;

    /**
     * Session was started
     *
     * @var bool
     */
    protected $started = false;

    /**
     * All items
     *
     * @var array
     */
    protected $items = [];

    /**
     * Options list
     *
     * @var array
     */
    protected $options = [];

    /**
     * Constructor
     *
     * @param array $options
     */
    public function __construct(array $options = [])
    {
        if (array_key_exists('name', $options) && !is_string($options['name'])) {
            throw new \InvalidArgumentException('Session name must be string value');
        }

        if (isset($options['name'])) {
            $this->sessionName = $options['name'];
        }

        $this->options = $options;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return $this->sessionName;
    }

    /**
     * {@inheritdoc}
     */
    public function start()
    {
        if ($this->isStarted()) {
            return false;
        }

        $this->started = true;

        return $this->started;
    }

    /**
     * {@inheritdoc}
     */
    public function stop()
    {
        if ($this->isStarted()) {
            $this->started = false;
        }
    }

    /**
     * {@inheritdoc}
     */
    public function isStarted()
    {
        return (bool) $this->started;
    }

    /**
     * {@inheritdoc}
     */
    public function get($key)
    {
        $key = (string) $key;

        return array_key_exists($key, $this->items) ? $this->items[$key] : null;
    }

    public function getItems()
    {
        return $this->items;
    }

    /**
     * {@inheritdoc}
     */
    public function set($key, $value)
    {
        $this->items[(string)  $key] = $value;
    }

    /**
     * {@inheritdoc}
     */
    public function remove($key)
    {
        unset($this->items[(string) $key]);
    }

    public function clear()
    {
        $this->items = [];
    }
}