Session.close event fails to fire in cgi app

I have some code in Session.Close event which tidies up a database when user closes browser, or navigates away from the app.

When I test run the app from the ide (on a win7 pc), the close event works and performs as expected.
However, when the same app is run as a cgi on Apache server, it seems that the close event code never runs.
Even if I wait 10 - 15minutes after closing the browser, the database tidy never happens.

Exactly the same database and same app code works perfectly when test-run from the ide.

(Yes, all references in the code to “Session” are made via “self”)

Any ideas?

can you reproduce in small project and fill a feedback case?

Maybe there is an extra reference somewhere to session object?

OK, I’ll see if I can build a small test app that demo’s the problem…

Which version of the IDE are you using?

2014 r2

I am curious to see here if there is really a problem. I will need the session.close also in a project I am currently working on.

OK! Have now experimented with a test app. I have established that the Close Event does indeed trigger correctly on the cgi app approx 3 minutes after the browser window is closed (or the tab of the window is closed / or you browse to another web site from the current tab).

The close event seems to never fire if you use a button to call “Session.quit” action and you leave the window tab open. If you refresh the window following a Session.quit action you will get a new Session ID, but the old session still does not trigger its Close Event (unless you close the browser).

When run from IDE the Close event triggers about 10 seconds after closing the browser. If you call the Session.quit action the Close Event does not trigger all the while you leave the browser tab open. Refreshing the browser will create a new Session ID, but then the previously quitted session will trigger its close event several minutes later!

So, the above mentioned problem must be my bad, so it’s not a Xojo issue…

Joost, I can post a copy of my test app, if you want to play with it?

Cheers!

[quote=114827:@Tony Davies]I have some code in Session.Close event which tidies up a database when user closes browser, or navigates away from the app.

When I test run the app from the ide (on a win7 pc), the close event works and performs as expected.
However, when the same app is run as a cgi on Apache server, it seems that the close event code never runs.
Even if I wait 10 - 15minutes after closing the browser, the database tidy never happens.

Exactly the same database and same app code works perfectly when test-run from the ide.

(Yes, all references in the code to “Session” are made via “self”)[/quote]

You probably need to set Session.Timeout for the time the user has ceased activity and place an explicit Quit in the Session.TimedOut event for Close to fire.

The Session.Quit issue is a known issue in 2014r2. If you need to disconnect a user, redirect them away from your app and let the session die on its own.

If you could do so Tony, that would be nice. I’ll let you know how it works for me. I am running web-app with 1701.

Don’t do that in 2014r2. It actually exacerbates the problem.

Since you mention just 2014r2 having this issue … a fix in 2014r2.1 would be appreciated.

As it was only reported two days ago, I can make no promises.

Hi guys, thanks for all your input.
Yes, I do not use session.quit action in any of my commercial apps, but just thought I would experiment with it in the test app (Test App project is attached for your interest - place the sqlite db file in your project folder for local testing, or place it in the App’s cgi-bin folder for testing on a web server).

link text

Greg, I can confirm that the Session.Close event functions correctly if user navigates away from the app, or closes the browser.

Thanks for sharing Tony.

So just a showURL(“http://mysite.com/exitpage.html”) instead of quit, right ?

Right. As long as it doesn’t start a new session.

If the fix does not make it into 2014r2.1, should we expect it in 2014r2.2 or 2014r3?

As greg said

Not looking for promises, just an idea of when we might see it fixed.