Fixed a bug in saving session keys