<?php
/*
 * Software Name: Eorisis Pixels
 * Software URI: https://eorisis.com/shop/software/joomla/pixels
 * Author: Eorisis
 * Author URI: https://eorisis.com
 * Copyright: Copyright (C) 2011-2025 EORISIS. All Rights Reserved.
 * License: GNU General Public License version 2; See https://eorisis.com/gpl
 * Terms of Service: https://eorisis.com/tos
 */
namespace com_eorisis_pixels\framework\lib\core\cms;
\defined('_JEXEC') or die;

use JLoader, EorisisFactory, EorisisSession;

if (\version_compare(JVERSION, '3.8', '>='))
{
	JLoader::registerAlias('EorisisFactory', '\\Joomla\\CMS\\Factory');
	JLoader::registerAlias('EorisisSession', '\\Joomla\\CMS\\Session\\Session');
}
else
{
	JLoader::registerAlias('EorisisFactory', 'JFactory');
	JLoader::registerAlias('EorisisSession', 'JSession');
}

class session
{
	public function __construct() {}

	// --------------------------------------------------

	public static function obj()
	{
		if (\version_compare(JVERSION, 4, '>='))
		{
			return EorisisFactory::getApplication()->getSession();
		}

		return EorisisFactory::getSession();
	}

	// --------------------------------------------------

	public static function get(string $name, $default = null, string $namespace = 'default')
	{
		return self::obj()->get($name, $default, $namespace);
	}

	// --------------------------------------------------

	public static function set(string $name, $value = null, string $namespace = 'default')
	{
		return self::obj()->set($name, $value, $namespace);
	}

	// --------------------------------------------------

	public static function token(bool $force_new = false) : string
	{
		return EorisisSession::getFormToken($force_new);
	}

	// --------------------------------------------------

	public static function add_keep_alive() // void
	{
		\com_eorisis_pixels\framework\lib\core\cms\document::html_display('behavior.keepalive');
	}
}
