saveSession method
Saves session to Memory, Disk, and Index.
Implementation
Future<void> saveSession(AuthUserSession session) async {
if (session.userId.isEmpty) return;
String userId = session.userId;
// Memory
_memorySessions.removeWhere((s) => s.userId == userId);
_memorySessions.add(session);
// Storage
await _storage?.writeJson(_userSessionKey(userId), session.toJson());
// Index
await _updateIndex(userId, add: true);
// Update Active Reference if applicable
if (_activeSession?.userId == userId) {
_activeSession = session;
}
}