Page 1 of 1

Tab close or browser close should logout the system.

PostPosted: Thu Sep 08, 2016 7:03 am
by satya.sahu
Hi

I am using servoy 7.4.1(web client).
Is there any way is there when user close the tab or close the browser then it should log out the solution ?
Or Is there any way when the user close the tab or browser, then next time user click on new tab or new browser and type the url then it should log out the solution instead of loading the previous session.

Thanks,
Satya

Re: Tab close or browser close should logout the system.

PostPosted: Thu Sep 08, 2016 8:44 am
by Bernd.N
Hi Satya,
though I have no answer for your question, I recommend a supporting measure to ask users to always logout properly.

You could use a flag that gets set when a user logs in, and gets null when the user logs out as she should.
Then on login, you can show a message to ask the user to always use the proper way to logout.
Additionally, you could set a counter to detect those users who ignore this constantly. :wink:

This is the code we use on login.
In your logout method, you just set the flag then to null, so the flag would stay for users that do not use your intended logout button.
Code: Select all
      if (_to_person$currentpersonid.ps_did_not_logout_properly === 1) {
      
         // Count up
         _to_person$currentpersonid.ps_did_not_logout_properly_num += 1;
         
         scopes.ui.getDialog("ps_please_use_logout");
      }
      
      _to_person$currentpersonid.ps_did_not_logout_properly = 1;


Re: Tab close or browser close should logout the system.

PostPosted: Thu Sep 08, 2016 9:52 pm
by sbutler

Re: Tab close or browser close should logout the system.

PostPosted: Fri Nov 04, 2016 9:26 am
by satya.sahu
Thanks for the reply

But My requirement is like when i close the tab or close the browser it should log out the system. I am using the following JQuery code but its not working.
' $(window).on("unload",function() {' +
plugins.WebClientUtils.generateCallbackScript(scopes.navigation.runMenuHandlerServoy, ["logout"]) +
'});'
The method scopes.navigation.runMenuHandlerServoy keeps the logout logic. Any way when I am closing the tab its not calling that method as well its not log out the user, The problem is that when user type the same url its loading previous session data and solution is not working properly.

Thanks
Satya

Re: Tab close or browser close should logout the system.

PostPosted: Fri Nov 04, 2016 10:09 am
by Gordon McLean
satya.sahu wrote:Hi

I am using servoy 7.4.1(web client).
Is there any way is there when user close the tab or close the browser then it should log out the solution ?
Or Is there any way when the user close the tab or browser, then next time user click on new tab or new browser and type the url then it should log out the solution instead of loading the previous session.

Thanks,
Satya


This is a long overdue feature that Servoy Webclient prevents by the very nature of the way it works, constantly poling the server. What would be idea is a plugin or function that allowed the developer to set the time out for inaction on the page and take the user back to login or a friendly reminder page. It both sucks up client licenses that could otherwise be used for new users and makes the page unresponsive when/if the user does return whilst it reconnects. As for educating users to log out this is a nice idea but in practice just does not work.

Re: Tab close or browser close should logout the system.

PostPosted: Sat Nov 05, 2016 9:58 am
by satya.sahu
Any help from Servoy forum?

Re: Tab close or browser close should logout the system.

PostPosted: Sat Nov 05, 2016 1:20 pm
by rgansevles
Hi,

Not directly answering the question, but fyi, this is a feature built-in for the ng-client (Servoy 8).

When the user closes the browser tab (or navigates to another url in the same tab), the ng-client will be closed after a small period.
When the user returns to the page within this period, the session will be reconnected, and the user continues where it was.
This allows for resilience in case of short network outages.

The period is 60 seconds by default and can be configured via setting sablo.window.timeout.secs on the admin page, see https://wiki.servoy.com/display/DOCS/NG+Client+Settings

Rob

Re: Tab close or browser close should logout the system.

PostPosted: Mon Nov 07, 2016 12:46 pm
by pbakker
Rob,

The link you point to is not publicly available.

Secondly: is there a way to disable this timeout from within a NGClient sessions, because this behavior is problematic when for example you (temporarily) redirect the user to another website, for example for oAuth authentication. The 60 seconds interval is too short

Paul

Re: Tab close or browser close should logout the system.

PostPosted: Tue Nov 08, 2016 12:59 am
by rgansevles
Hey Paul,

I expected the page to be published, I asked Johan to fix this.
Thanks for that.

The window timeout is a static setting now, but I think it could be made overridable, for instance via application.putClientProperty().
When you file a request it will be looked at.

Rob

Re: Tab close or browser close should logout the system.

PostPosted: Tue Nov 08, 2016 9:59 am
by pbakker