Kill Session on Window Close?

Forum to discuss the Web client version of Servoy.

Kill Session on Window Close?

Postby bcusick » Tue Jan 08, 2019 7:11 pm

Hey Guys,

I have a problem with users not clicking a "log out" button to end their session, but just closing the window. When they come back (after 10-90 minutes) - they just use "back" in the browser, or re-login and their old session is there (server seems to ignore the 20 minute timeout). This causes the application to appear "frozen"...

Is there a way to "log out" when closing the window?

Bob
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Re: Kill Session on Window Close?

Postby sbutler » Thu Jan 10, 2019 6:24 pm

What I've always done for Web Client apps is to not have them link directly to the web client url. The reason for that is it includes the session id in the URL, and so then its in their browser history. They bookmark it, use the back button, etc, and it all goes to hell.
So I replace the index.html file (or make like a new app.html) in application_server/server/webapps/root with something like this below. It loads the web client URL into an iframe (either http or https depending on how the loaded the page). So, when the user goes to https://yourapp.com and it hits index.html, it loads https://yourapp.com/servoy-webclient/ss/s/myApp into an iFrame with no border that takes up all the page.

The result is if they leave and go back, it starts a new session if the prior one was expired. If it wasn't expired, it loads the prior session from the cookies that servoy sets.

If you want the sessions to expire more often and have more control of it. You can use the UserManager plugin, or built-in ClientManager plugin if you are on a more recent version of Servoy. They both have the ability to get idle time of clients and shut them down.

Code: Select all
<html>
<head>
<title>My App Name</title>
<style type="text/css">
html {overflow: auto;}
html, body, div, iframe {margin: 0px; padding: 0px; height: 100%; border: none;}
iframe {display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden;}
</style>
</head>
<body>

<iframe id="servoyFrame" src="" width="100%" height="100%" frameborder="0" border="0" scrolling="auto">

  <p>Your browser does not support iframes.</p>

</iframe>

<script type="text/javascript">

if (window.location.protocol != "https:")
   window.location.href = "https:" + window.location.href.substring(window.location.protocol.length);
var host = "https://" + window.location.host;
var url = host + "/servoy-webclient/ss/s/myApp";
document.getElementById('servoyFrame').src = url;

</script>

</body>
</html>
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Kill Session on Window Close?

Postby bcusick » Thu Jan 10, 2019 6:46 pm

AH! OK. I think that will work for this particular application.

I'll give it a whirl and see if it works!

I REALLY APPRECIATE your response, Scott! :)
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 2 guests