Fixed a KeyError on login with legacy sessions; refs #21649.