PHP使用session_set_save_handler陷阱
陷阱如下 当脚本使用了session_set_save_handler 来重定向 session后,使用session_destroy后再使用session_start()重新开启session会报错 代码如下, <?php function open() { echo 'session start'; echo "\n"; } function close() { echo 'session close'; echo "\n"; } function read($sessionId) { echo 'read'.$sessionId; echo "\n"; } function write($sessionId, $data) { echo 'write'.$sessionId.$data; echo "\n"; } function destroy($sessionId) { echo 'destroy '.$sessionId; echo "\n"; } function gc($lifetime) { echo 'gcccc'; echo "\n"; } session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); session_start(); echo session_id()