added a session save function.