HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/slfopp7cb1df/www/home/wp-content/plugins/mailoptin/src/authifly/src/Storage/Session.php
<?php
/*!
* Authifly
* https://hybridauth.github.io | https://github.com/mailoptin/authifly
*  (c) 2017 Hybridauth authors | https://hybridauth.github.io/license.html
*/

namespace Authifly\Storage;

use Authifly\Exception\RuntimeException;
use Authifly\Deprecated\DeprecatedStorageTrait;

/**
 * AuthiFly storage manager
 */
class Session implements StorageInterface
{
    /**
     * Namespace
     *
     * @var string
     */
    protected $storeNamespace = 'AUTHIFLY::STORAGE';

    /**
     * Key prefix
     *
     * @var string
     */
    protected $keyPrefix = '';

    /**
    * Initiate a new session
    *
    * @throws RuntimeException
    */
    public function __construct()
    {
        if (session_id()) {
            return;
        }

        if (headers_sent()) {
            throw new RuntimeException('HTTP headers already sent to browser and Authifly won\'t be able to start/resume PHP session. To resolve this, session_start() must be called before outputing any data.');
        }

        if (! session_start()) {
            throw new RuntimeException('PHP session failed to start.');
        }
    }

    /**
    * {@inheritdoc}
    */
    public function get($key)
    {
        $key = $this->keyPrefix . strtolower($key);

        if (isset($_SESSION[$this->storeNamespace], $_SESSION[$this->storeNamespace][$key])) {
            return $_SESSION[$this->storeNamespace][$key];
        }

        return null;
    }

    /**
    * {@inheritdoc}
    */
    public function set($key, $value)
    {
        $key = $this->keyPrefix . strtolower($key);

        $_SESSION[$this->storeNamespace][$key] = $value;
    }

    /**
    * {@inheritdoc}
    */
    public function clear()
    {
        $_SESSION[$this->storeNamespace] = [];
    }

    /**
    * {@inheritdoc}
    */
    public function delete($key)
    {
        $key = $this->keyPrefix . strtolower($key);

        if (isset($_SESSION[$this->storeNamespace], $_SESSION[$this->storeNamespace][$key])) {
            $tmp = $_SESSION[$this->storeNamespace];

            unset($tmp[$key]);

            $_SESSION[$this->storeNamespace] = $tmp;
        }
    }

    /**
    * {@inheritdoc}
    */
    public function deleteMatch($key)
    {
        $key = $this->keyPrefix . strtolower($key);

        if (isset($_SESSION[$this->storeNamespace]) && count($_SESSION[$this->storeNamespace])) {
            $tmp = $_SESSION[$this->storeNamespace];

            foreach ($tmp as $k => $v) {
                if (strstr($k, $key)) {
                    unset($tmp[ $k ]);
                }
            }

            $_SESSION[$this->storeNamespace] = $tmp;
        }
    }
}