Could you shed some light on session expiry please?

Hi,

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?

Expired sessions are cleared automatically in SessionCheckInterval min. by default it is 15 .

Yeah I worked that out trawling through the code.

So is it advisable to call ClearSessions(TRUE) before calling FindSession, or to handle any possible EROSessionExpired exception from FindSession?

You can call GetAllSessions and work directly with received list

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.

weird, because GetAllSessions returns only list of non-expired sessions. you can check it in TROInMemorySessionManager.DoGetAllSessions.

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.

Thanks.