1--TEST-- 2Bug #32330 (session_destroy, "Failed to initialize storage module", custom session handler) 3--EXTENSIONS-- 4session 5--INI-- 6session.use_trans_sid=0 7session.use_cookies=1 8session.name=sid 9session.save_path="{TMP}" 10session.gc_probability=1 11session.gc_divisor=1 12--FILE-- 13<?php 14error_reporting(E_ALL); 15 16class MySessionHandler implements SessionHandlerInterface { 17 function open($path, $name): bool 18 { 19 echo "open: path = {$path}, name = {$name}\n"; 20 return TRUE; 21 } 22 23 function close(): bool 24 { 25 echo "close\n"; 26 return TRUE; 27 } 28 29 function read($id): string|false 30 { 31 echo "read: id = {$id}\n"; 32 return ''; 33 } 34 35 function write($id, $data): bool 36 { 37 echo "write: id = {$id}, data = {$data}\n"; 38 return TRUE; 39 } 40 41 function destroy($id): bool 42 { 43 echo "destroy: id = {$id}\n"; 44 return TRUE; 45 } 46 47 function gc($maxlifetime): int 48 { 49 echo "gc: maxlifetime = {$maxlifetime}\n"; 50 return 1; 51 } 52} 53 54session_set_save_handler(new MySessionHandler()); 55 56// without output buffering, the debug messages will cause all manner of warnings 57ob_start(); 58 59session_start(); 60$_SESSION['A'] = 'B'; 61session_write_close(); 62 63session_start(); 64$_SESSION['C'] = 'D'; 65session_destroy(); 66 67session_start(); 68$_SESSION['E'] = 'F'; 69// Don't try to destroy this time! 70 71?> 72--EXPECTF-- 73open: path = %s, name = sid 74read: id = %s 75gc: maxlifetime = %d 76write: id = %s, data = A|s:1:"B"; 77close 78open: path = %s, name = sid 79read: id = %s 80gc: maxlifetime = %d 81destroy: id = %s 82close 83open: path = %s, name = sid 84read: id = %s 85gc: maxlifetime = %d 86write: id = %s, data = E|s:1:"F"; 87close 88