Question
· Sep 6, 2016

How to end a session or clean up license if a tab is simply closed

If a user simply closes a tab (running a web application), is there any good way to ensure that the license is released AND the login cookie is destroyed?  

 

I found that if the tab is simply closed without first logging out of the application, then 1) the license hangs around forever, and 2) if the user then opens a tab, he is already logged in.

 

For #2, I understand that there might be some grace period to allow the user to log in automatically again using the same session Id (where is that documentation again?) but what about destroying the license?  Who/what is supposed to clean that up?

Thanks,

Laura

Discussion (5)0
Log in or sign up to continue

Closing Tab in the browser, does nothing on the server side, because in simple way, browser only ask server by user's requests.

You can only do some ajax request just when user closes the page, to close session on the server side, no more.

Every session will be alive in their Timeout, that Timeout could be get by default from settings, or you can set it programmatically ( set %session.AppTimeout=900), and only when timeout is exceeded the used grace period 5 minutes. And only after that session and license will be released. 

And you should remember, that if user closed tab, he can open it again, and it will be the same session as before.

I'll look into the AJAX thing, thanks.  

We do set an AppTimeout, and upon timeout we ask the user first if he really wants to timeout.  If so, then the session is logged out, not timed out, and the license is released.  But, this is only if the user is good and either accepts the timeout or logs out with the logout link.

 

If he closes the browser (bad user) then the license is not released.  We have some that have been active for 11 days, and I know they're not being used.

 

I'll see if I can catch a 'close' just before the tab or browser closes.

 

Is there a way to tell cache to remove the license if nothing has been done with it in, say, 24 hours?

There is a beforeunload HTTP event which is fired when the window, the document and its resources are about to be unloaded. Handle this event in your js code and from there you can send an HTTP request to a server (I usually use GET /webapp/logout), which would do something like this:

ClassMethod logout() As %Status
{
    #dim %session As %CSP.Session
    set st = %session.Logout(1)
    set %session.EndSession = 1
    return st
}

I was playing around with that... actually I was looking at the ZEN version "onunloadHandler".  From  the documentation: "This client-side page method, if defined, is called when the client page is about to unload. It is triggered by the page’s HTML onbeforeunload event."

But it was causing a popup to appear when the user is simple navigating around the application -- of dozens of pages.  I assume each page is unloading before the next one appears.

I wonder if I have access to the URL of the next page.

I'm really surprised HTML5 doesn't have something like this yet, to capture a tab/browser close event rather than just an unload.

Anyway, thanks -- I'll see what I can do.

 

Laura