Saves online state in database