Write session data to a file