WebApp.SessionAtIndex(n).Quit not working?

I am trying to kill previous sessions with App.SessionAtIndex(i).Quit, and it doesn’t seem to be working.

In my App.Session.Open event I have the following…
Dim k As Integer = 0
For i As Integer = 0 To App.SessionCount - 1
If App.SessionAtIndex(i) <> Self Then
MsgBox “We have closed “+str(k)+” other sessions.”

When I open a new session, the message displays as expected. First instance k is 0. The next session I open k shows up as 1. The next, k is 2. Since I am Quitting previous sessions, I would NOT expect k to not keep climbing - but it has up to 11 tested so far.

I also placed a label on my web app with this code in the MouseDown event…
me.Text = "Session Count: "+str(App.SessionCount)

When clicking on the label, it confirms the same info from k above (incremented by 1, because it is including the current session).

Why isn’t App.SessionAtIndex(i).Quit killing the sessions as I expect it to?

Apologies… should be “… I would NOT expect k to [—] keep climbing …”.
Forgive the accidental double-negative.

If you have created and stored a reference to a WebSession or a WebControl in a session which has not been released, it’s possible that this count would never decrease.

Also, keep in mind that looping through the sessions the way you do, you’re going to miss some because when a session is removed from the array, all of the sessions above it move downward. Better to do this:

Dim c as Integer = App.SessionCount-1 //So you only call this method once For i As Integer = c downto 0 ...

Just out of curiosity, how long are you waiting to check if the previous sessions have quit? I’m looking at the code and it appears that they don’t get killed immediately. We just send a message to the browser telling it to disconnect and then the framework still waits until it hasn’t heard from the app for a few minutes before cleaning up the server side of things.

I like the code proposal - thanks. I do not have any references to sessions or controls in sessions (aside from the If App.SessionAtIndex(i) and App.SessionAtIndex(i).Quit references above.

Experimentation is suggesting that the sessions are staying “alive” if the browser tab that contained that session is still alive (even though the screen for that tab has blanked). I closed on of these tabs, and eventually (after some nominal period of time - a minute or so?) the count went down by one. But as long as the other tabs are present (even after about 10-15 minutes so far) the count appears to keep including them.

It looks like it works OK as long as invoke the new sessions all in the same browser tab, so additional tabs are not holding the sessions open.

If I keep hitting REFRESH on the browser, the session count might get as high as 3, but quickly backs down to 1. So perhaps things are working as should be expected - understanding that the browser tab is the culprit for holding the session alive, even though the user no long has access to that session, because the screen as blanked. FYI, REFRESHING a blank tab (via the browser) does not re-initialize the session for the user - the tab stays unusable - I assume that is also expected?

File a bug report. I think I know what’s going on.

For the mean time, you could call Quit and then do a ShowURL to redirect the user away from the app.

Will do. Thanks.

I am not sure I know how to ShowURLs for OTHER sessions - is that possible? (I don’t want to do that for the current active session).

FYI: 34335 - Can’t kill websession with App.SessionAtIndex(i).Quit

[code]dim sess as WebSession
dim page as WebPage

sess = app.SessionAtIndex(i)
page = sess.PageAtIndex(0)
if page <> nil then
end if

Perfect - thanks!