List

Try: ca/tecreations/ViewFile.php


<?php
require_once "AES256.php";

class AES256SessionHandler extends MySQLSessionHandler
{
    private $key;

    public function __construct($key)
    {
        parent::__construct();
        $this->key = $key;
    }

    protected function getKey() : string { return $this->key; }
    
    public function read($id,$key = "") : string
    {
        if ($key == "") $key = $this->key;
        $data = parent::read($id);
        if (!$data) {
            return "";
        } else {
            return decrypt($data, $key);
        }
    }

    public function write($id, $data,$key = "") : bool
    {
        if ($key == "") $key = $this->key;
        $data = encrypt($data, $key);

        return parent::write($id, $data);
    }
}
//$handler = new AES256SessionHandler("test");
//session_set_save_handler($handler,true);
//session_start();