Session time out on MWS

We’ve a requirement from our customer to show an alert window once the user session timesout on the MWS server.

I thought of writing a javascript timer to implement this but the problem will be if user just plays around the form without submitting the form, then my javascript thinks that the session is still alive where as the user’s session is timedout on the server.

The next thing i could think of is, set a javascript variable only if there is a request sent to the server (both sycn and async)

But i did not find a way to interpret the requests send to the server using javascript.

What i would like to know is my thought process right?
Is there any better solution for handling the user session timeout as we can provide suggestions to the customer if there is a better way to handle.

We’re on MWS version 7.1.3

Thanks in Advance for your help!

Here’s an approach recommended by one of our javascript experts:

Hi Mimel,
Thanks for the code snippet.
While i’m testing the session time out using the code snippet you provided,
I observed something.
I used the code snippet to just show an alert message whenever user doesnt interact with the system for 10s(which is way too low but just for testing).
In this case, whenever user submits a form like searches for something just before the session timeout probably 3-4 seconds before the time out. If the search takes longer time i.e around 10s to show the o/p on the screen. The alert still comesup on the screen.

Can we use a similar class as that of AJAX which checks for requests being sent and resets the counter.

I haven’t tried this, but i think that you can set a global listener for the Ajax.Request calls and add your own logic.

The provided Code snippet works just as we wanted and we have enhanced it by adding a countdown timer.

Just a catch though, for which we spent quite sometime to figure out.

There is a small typo in the very first line where variable is declared.

It must be

var waitForSessionTimeout


Good to hear. Sorry about the typo!