Alert when Session Expires

  
Hi guys,
I'm a little bit new in Outsystems and I'm trying to do something like a redirection and warning when the Session of a user expires by time.
I need to now the best way to detect this expiration and then send the user to a certain screen and then inform the user.
Can anyone explain me how to do this or even a sample oml with this?

Tks in Advance,
N.Taylor

Hi Nuno,

What you're trying to achieve it's not trivial.
First of all, the session timeout, (by default) is by idle time, meaning that it is the time that user its not interacting with the application (no post to the server). And if this is the case that you're tackling, then a simple javascript using a timer should be enough.

If you want, I may try to create an example and post it here.

Cheers,

RG
Hi Nuno,
You can do that using the Security Handler and redirect the user, for example, to the login page and then show a message if Session.UserId = null.
In this case you should this when the user try to do some action in the current screen.

Kind  Regards,
Gonçalo Martins
Gonçalo Martins wrote:
Hi Nuno,
You can do that using the Security Handler and redirect the user, for example, to the login page and then show a message if Session.UserId = null.
In this case you should this when the user try to do some action in the current screen.

Kind  Regards,
Gonçalo Martins
 Hi Gonçalo,

Your solution its the correct one, since it uses the full potencial of the Agile Platform. However, the user is only going to see that message/exception when it click on something or tries to do something, not sure if that is the case.

Cheers,

RG
 
Hi Rúben and Goncalo,

Thank for your tips..But since I'm not very proficient with the platform, could you show me a small example (maybe 2screens and the logic for both cases - javascript and Outsystems).
Sorry about it but it would be very important to my learningof Outsystems.


Nuno,

Before doing it, can you tell us, exactly the behaviour that you're looking for?
Hi Ruben,
Thank you first of all.
Basically my requirement is to inform a user when his session expires, to enable him to understand the reason and redirect him to the login page (where the message or feedback could be shown if that happens).
If you could show me the Outsystems solution for this in the oml it would be great.


Nuno,

The change is pretty straighforward:



However in attachment you may find the eSpace.

Let me know if it helps.
That's it Rúben..
Simple as that..:)

- Nuno:
Any additional doubt just say it and good luck with the Agile Platform.

Kind Regards,
Gonçalo Martins


Thanks a lot guys..
However, I think  I'll need a more visual and intuitive way..
If for example we are in a certain screen and the session expires, the user should be informed instantly with a message and after that redirect to the login.
When he enter his credencials he should return to the page from where he came..
I think that Ruben mentioned this case using javascript..but I don't know how.. :s
Anyone could help me with this??
My skills aren't still enought to implement a solution for it...

Thanks in advance..
Nuno,

Have you gone through the tutorials ?
A lot of it is explained there ... otherwise look for a short training on the platform, like going to a developers bootcamp
Nuno Taylor wrote:
Thanks a lot guys..
However, I think  I'll need a more visual and intuitive way..
If for example we are in a certain screen and the session expires, the user should be informed instantly with a message and after that redirect to the login.
When he enter his credencials he should return to the page from where he came..
I think that Ruben mentioned this case using javascript..but I don't know how.. :s
 Hi Nuno,

The eSpace that I sent you, does exacly that (shows a message once the user arrives to the login page).
Additionally, I agree Joop, take some time, and do at least the tutorials, they will help you to ramp up.

Cheers,

RG
 
Hi Ruben and Joop,

Thanks a lot for the advices and I already started to see the tutorials.
However, my doubt is very specific and urgent for this issue in the project I'm working.
Ruben spoke about using javascript and the idle timeof the session (I don't know the value of that time) and I would like to know how that is done, since the redirect part I already understood.
Can anyone give me an example oml where we do that automatically when in a screen?

Thank yout very much
Hi Nuno,

You want to show a message before redirecting the user to the login page?
First of all, the session timeout is defined at as explained in this post in the machine.config file, with that, you just need to do a JS timer that you'll add to all pages and that you'll need to restart each time the user either goes to a page or does an ajax request. This will make your application both harder to maintain and to understand. 

Hope it helps.
Nuno -

Are you sure that this is your real requirement? If you use "Remember Password" then they won't need to re-login.

J.Ja
Nuno,
I agree with Justin, since that is an usual feature.
Check with your client this issue, but also keep in mind the security problems that can arrive with both cases.

Regards,
Gonçalo Martins
Nuno -

One problem you will run into, is that any request back to the server to check status will reset the session timer if they occur before the session expires. So what you need to do is actually have the JavaScript check a bit after the session should expire. Probably the easiest thing to do is use SetInterval to click a hidden button (use style="display: none;", setting "Visible" = False will cause it to not be sent to the screen at all), and that button will call an action. That action will verify that the Session.UserId = NullIdentifer(), then put a message on the screen about the redirect. You can either use AddMetaTag to pass a redirect header to send them to login after a few seconds (do NOT hardcode the URL, use "GetEntryURL" and make an entry to the login page), or better yet, click another hidden on-screen button or link to send you back to login.

J.Ja