<?php class Session_Database{ public function close(){} } class Session { private Session_Database $db; public function __construct(){ // Instantiate new Database object $this->db = new Session_Database(); // Set handler to overide SESSION session_set_save_handler( [$this, '_open'], [$this, '_close'], [$this, '_read'], [$this, '_write'], [$this, '_destroy'], [$this, '_gc'] ); // Start the session session_start(); } public function _open(string $savePath, string $sessionName): bool {return true;} public function _read(string $sessionId): string {return '';} public function _write(string $sessionId, string $data): bool {return true;} public function _destroy(string $sessionId): bool {return true;} public function _gc(int $lifetime): bool {return true;} public function _close(): bool { echo 'closing session'; // Close the database connection $this->db->close(); return true; } } new Session; session_write_close();
You have javascript disabled. You will not be able to edit any code.