write session when changed