File Manager / wp-content Search Upload New Item Settings File "db5.php" Full path: /home1/epichome/public_html/wp-content/db5.php File size: 60.67 B (60.67 KB bytes) MIME-type: text/x-php Charset: utf-8 Download Open Edit Advanced Editor Back
/home/pabloaso/public_html/wp-content/plugins/woocommerce-mercadopago/src/Helpers/Session.php
<?php

namespace MercadoPago\Woocommerce\Helpers;

if (!defined('ABSPATH')) {
    exit;
}

class Session
{
    /**
     * Get session
     *
     * @param string $key
     *
     * @return array|string|null
     */
    public function getSession(string $key)
    {
        if ($this->isAvailable()) {
            return WC()->session->get($key) ?? null;
        }

        return null;
    }

    /**
     * Set session
     *
     * @param string $key
     * @param mixed $value
     *
     * @return void
     */
    public function setSession(string $key, $value): void
    {
        if ($this->isAvailable()) {
            WC()->session->set($key, $value) ?? null;
        }
    }

    /**
     * Delete session
     *
     * @param string $key
     *
     * @return void
     */
    public function deleteSession(string $key): void
    {
        if ($this->isAvailable()) {
            $this->setSession($key, null);
        }
    }

    /**
     * Verify if WC_Session exists and is available
     *
     * @return bool
     */
    public function isAvailable(): bool
    {
        return WC()->session !== null;
    }
}