Atozed Forums

Full Version: closing browser...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

How to close user session if the user close the browser…

With best regards,
Mikey
Hi, IW does it for you automatically.
Hello JPN,

Yes after the session time is over…

I 'm looking for a way to force to end the session in order to free memory on the serveur…
But it seem's that there is no one, except waiting the time session is over…

Big thank you answer.
Mikey
Correct. A timeout is the only reliable way to do this.
(05-31-2018, 03:27 PM)Mikey29 Wrote: [ -> ]Hello JPN,

Yes after the session time is over…

I 'm looking for a way to force to end the session in order to free memory on the serveur…
But it seem's that there is no one, except waiting the time session is over…

Big thank you answer.
Mikey

As stated, the way the session ends is with a timeout.  But, you do have some control over that timeout and how you manage session shutdown.  There are a couple of settings you want to look into.

The first is the session timeout setting itself.  You can set it as a ServerController property or at runtime as, for example, ASession.SessionTimeout in ...BaseNewSession event.  You can shorten the timeout considerably so that when the form is closed the session will end much sooner.

The second setting to consider is IWForm.KeepAlive.  Note that this is NOT the HTTP KeepAlive.  If you set the Form.KeepAlive to true then the form will "ping" the server to keep the SessionTimeout from occurring.  It pings 3 or 4 times during the SessionTimeout period so the shorter the timeout, the more often it pings. This setting is in each form, so must be set for the form.

By combining these two you can have the session open for as long as you want, but close fairly quickly when the form disappears. 

A caveat... some browsers stop processing when they lose focus, so the KeepAlive does not execute.  So far as I know only mobile browsers behave this way.  I use a different timeout based on whether a browser is mobile or not.

Dan