ERSessionInfo info = ERSessionInfo.clazz.objectMatchingKeyAndValue(ec, ERSessionInfo.SESSION_ID_KEY, session.sessionID());
if(info == null) {
info = ERSessionInfo.clazz.createAndInsertObject(ec);
info.setSessionID(session.sessionID());
}
NSTimestamp expires = new NSTimestamp(System.currentTimeMillis() + session.timeOutMillis());
info.setExpirationDate(expires);
try {
/*
* An error here can later hang the instance when the session is restored.
* If the session fails to archive, delete it.