Save and restore credentials