Better visualization of I/O error when writing cookie
Various fix to match recent Moodle changes.