Save codes to the server and restore on connection