fix session write