force log off when browser closes

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

force log off when browser closes

#1

Postby Segi » Wed Dec 02, 2015 1:01 am

I'm using the system securityManager to authenticate my users and discovered that when you close the browser, the users' session remains active. If they re-open the browser, they do not need to log in again unless they specifically logged off before closing the browser.

Is there a way to end their session when they close the browser so that they have to log in again when they re-open the browser ?
0 x

Steve
Moderator
Moderator
Posts: 421
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

#2

Postby Steve » Wed Dec 02, 2015 3:07 pm

Hi Segi,

This is quite a tricky thing you want to do. I do not think that you can detect the browser closing (you might want to search the internet more to confirm this). You can only detect whether some one leaves the page.

To do this, you can use JQuery unload call to invoke a client callable function from the browser:

Code: Select all

$(window).on('unload', function(){

        $eb.executeFunction("endUserSession");
});
The Client callable script on the server will look like this:

Code: Select all

function endUserSession()
{
  client.getHttpSession().invalidate()
}
I am not 100% sure whether this will work and I have not tested this. Also this probably will not work if you are using callform.

Steve
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#3

Postby Jon » Wed Dec 02, 2015 4:19 pm

When a user signs on, the signon details are maintained at session level. When they connect with a new session, they must re-authenticate. In general, if you shut down the browser and restart, a new session is created. Most browsers behave like this. Which browser are you using, and which version?
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#4

Postby Segi » Fri Dec 04, 2015 12:27 am

I am using Firefox for development and testing. Most of my users are using Google Chrome though and Chrome seems to correctly sign you out when you close the browser but Firefox does not.

Just some additional info. I use the standard Firefox and Firefox developer preview and this happens in both Firefox variants.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#5

Postby Jon » Fri Dec 04, 2015 3:18 pm

My Firefox creates a new session when I shut it down and then restart. You may have Firefox option Open new windows in a new tab instead unchecked on your system (which is not the default). If you do this, each new tab is opened in a separate window, but then shutting down that specific window doesn't end the session because other windows still exist.

For info, no browsers do anything special when they close i.e. they don't notify the server, so the session on the server is still maintained - until it times out. It's the subsequent restart of the browser that is the important part - the browser should then request a new session.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#6

Postby Segi » Fri Dec 04, 2015 4:17 pm

Jon,

Open new windows in a new tab is checked in both instances of Firefox.
0 x


Who is online

Users browsing this forum: No registered users and 19 guests