I’m trying to wrap my head around session expiry after coming across an issue. Basically I’m using the session manager’s FindSession method in a few places but, if a session is marked as expired, it throws an exception.
How are expired sessions dealt with? It seems that expired sessions remain in the session manager’s list but are simply marked as expired rather than actually deleted. Is this the case? Will they remain there indefinitely or be cleared out on some kind of schedule?
It would seem that I can call the ClearSessions(True) method to remove all expired sessions prior to calling FindSessions, is this advisable to avoid the possibility of an exception being thrown?
That’s actually what I’m doing - it returns a list of session IDs which I then supply in turn to FindSession to get the actual session object, but if the session has expired, FindSession throws an exception.
EDIT: Actually, now I check, it seems that GetAllSessions should only return non-expired sessions, which makes this very strange.
Ah sorry, my mistake. The issues I was having weren’t in cases where GetAllSessions was called, this is fine. It was only cases where I was calling FindSession on a specific session ID which had expired.
I’ve implemented a wrapper function for FindSession via a helper class which deals with this scenario and all should now be fine.