You have to do this discretely, but I keep a notebook in my pocket and I will (sometimes) write the person's name down when I get a chance along with a note about who they are. This is even easier in smartphone age as everyone is checking their phones all the time anyway, just note the name there.