<commit_before><?php namespace core\utils;

final class Session
{
    public static function start()
    {
        session_start();
        return !self::timeout();
    }

    public static function stop()
    {
        if (session_id())
        {
            session_unset();
            session_destroy();
        }
    }

    private static function timeout()
    {
        if (self::get('app_session_time') && (time() > self::get('app_session_time'))) {
            self::stop();
            return true;
        } else {
            self::set('app_session_time', time() + SESSION_LIFETIME, true);
            self::set('app_session_token', Encryption::encode(md5(uniqid(rand(), true))));
            self::set('app_session_language', DEFAULT_LANGUAGE);
            return false;
        }
    }

    public static function set($key, $value, $force = false)
    {
        if (is_string($key) and (!isset($_SESSION[$key]) or $force)) {
            $_SESSION[$key] = $value;
        }
    }

    public static function get($key)
    {
        if (is_string($key) and isset($_SESSION[$key])) {
            return $_SESSION[$key];
        }
        return null;
    }

    public static function forget($key)
    {
        if (is_string($key) and substr($key, 0, 12) !== 'app_session_') {
            if (isset($_SESSION[$key])) {
                unset($_SESSION[$key]);
            }
        }
    }

    public static function token()
    {
        if (self::get('app_session_token')) {
            return Encryption::decode(self::get('app_session_token'));
        }
        return null;
    }
}
<commit_msg>Adicionado a variável de sessão app_session_encryption_key.<commit_after><?php namespace core\utils;

final class Session
{
    public static function start()
    {
        session_start();
        return !self::timeout();
    }

    public static function stop()
    {
        if (session_id())
        {
            session_unset();
            session_destroy();
        }
    }

    private static function timeout()
    {
        if (self::get('app_session_time') && (time() > self::get('app_session_time'))) {
            self::stop();
            return true;
        } else {
            self::set('app_session_time', time() + SESSION_LIFETIME, true);
            self::set('app_session_token', Encryption::encode(md5(uniqid(rand(), true))));
            self::set('app_session_encryption_key', ENCRYPTION_KEY);
            self::set('app_session_language', DEFAULT_LANGUAGE);
            return false;
        }
    }

    public static function set($key, $value, $force = false)
    {
        if (is_string($key) and (!isset($_SESSION[$key]) or $force)) {
            $_SESSION[$key] = $value;
        }
    }

    public static function get($key)
    {
        if (is_string($key) and isset($_SESSION[$key])) {
            return $_SESSION[$key];
        }
        return null;
    }

    public static function forget($key)
    {
        if (is_string($key) and substr($key, 0, 12) !== 'app_session_') {
            if (isset($_SESSION[$key])) {
                unset($_SESSION[$key]);
            }
        }
    }

    public static function token()
    {
        if (self::get('app_session_token')) {
            return Encryption::decode(self::get('app_session_token'));
        }
        return null;
    }
}

{'fraction_non_alphanumeric': 0.14414144441114773, 'fraction_numerical': 0.00239736290080911, 'mean_word_length': 2.026291931097008, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3924119', 'n_tokens_mistral': 984, 'n_tokens_neox': 965, 'n_words': 197}