class MySessionHandler extends SessionHandler { public function __construct() { } public function open($save_path, $session_id) { } public function close() { } public function create_sid() { } public function read($id) { } public function write($id, $data) { } public function destroy($id) { }} $handler = new MySessionHandler(); //第2個參數將函數 session_write_close() 註冊為 register_shutdown_function() 函數。session_set_save_handler($handler, true);