S
Sean Kinsey
On Apr 9, 10:13 am, Jorge wrote:
> > Don't do that either. --Antony
>
> So, what do you propose to ping the server from onunload ?
Sean's approach seems to be:
1. On navigating away from a page in the application,
send the server a message saying that you can
terminate my session now.
2. But if you've navigated to a page in the same app,
then send the server a message saying `Hey, I haven't
really navigated away, disregard my last message!'
That's got to be asking for trouble. My apologies if I've
misunderstood.
As I said, read the thread. Then perhaps you would have picked up on
this being a single page app, where only one instance is allowed at
any time, and so the only time this happens is when someone exits the
application without using the signout button.
And to clarify the steps
The server maintains a list of sessions, the clients pings the server
on intervals and extends the session. When the session expires it is
pruned.
1. On unload (close, navigate etc.) send a message to the server and
tell it to set the session to expire in e.g 10 secs
2 If it was only a refresh, then one of the first step the app takes
on load is to ping the server, and hence the session is restored.
It would be safer to start pinging the server as soon as you
connect to a page to let it know that you are still
connected. But why bother? If server resources are so low
that terminating users' sessions after two minutes (or
whatever) rather than thirty will really make that much
difference, then the problem lies elsewhere. It's the
server's responsibility to maintain its own resources. --Antony
This is not to save resources, this is to only allow a single sign on
at any time, and the only extra step here is actually the the single
call to shorten the expiration time.
And to prove that it enhances the user experience; in the worst case
scenario, if the server has just been pinged and the user accidentally
closes the browser, then they would have to wait for the session to
expire before being allowed back in.
I'm pretty sure we know what where doing here, so any criticism needs
to be specific and not based on some generalized notion of what is
'good' and what is 'bad'