Project

General

Profile

Destroy web session on page refresh

Added by Alan Finley over 10 years ago

Hello.

I have the reload-is-new-session option set to true, so every page refresh creates a new web session. This behaviour is fine for my needs.

But how can I get a previous active session destroyed after a page refresh?

I know that I can set the timeout to some small value, but I would like to have an option to explicitly kill my web app and destroy my worker threads when the user reloads the page.

If Wt does not provide it, can I somehow use the onbeforeunload event (or any other similar one) to implement it in my app?

I'm using Wt 3.3.1


Replies (3)

RE: Destroy web session on page refresh - Added by Wim Dumon over 10 years ago

Hey Alan,

Wt tries to sends a signal to the server when it leaves a page with onunload. It's not guaranteed to work for JavaScript in a browser to contact a server if the user has already left the page (or has reloaded it), which is why this signal does not always reach the server. If that's the case, we can only rely on the timeout mechanism to terminate the session. Success rates depend on browser and browser version. This is implemented in Wt.js.

Best regards,

Wim.

RE: Destroy web session on page refresh - Added by Alan Finley over 10 years ago

Then I don't get the difference between a tab close and a tab reload. In the the first case sessions are always destroyed, and in the second one - they are not.

RE: Destroy web session on page refresh - Added by Wim Dumon over 10 years ago

The behaviour of a browser is ill-defined in those cases, and the behaviour of one browser differs from the other. If you have a concrete suggestion to improve Wt's handling of session termination in these cases, we're surely interested to learn about it, but so far we haven't found a solution that works in all cases (and such solution may even simply not exist).

BR,

Wim.

    (1-3/3)