Wicket 9: allow user to prolong a session

Viewed 43

Let's say that user session is about to expire. Before it expires I want to give an opportunity to a user to prolong his / her session, i.e modal window asking to continue or invalidate session.

How to implement that in wicket 9?

Are there any hooks before a session is about to be invalidated?

1 Answers

There are no such hooks! The Servlet API does not provide such!

Even if there was such API then you have to use WebSocket connection because it is not possible to send something from the server to the browser without a http request. And a request will "touch" the http session and make it alive for another N seconds/minutes.

You have to implement this with JavaScript on the client side. Use setTimeout(showModal, N) and clearTimeout() to reset it whenever an Ajax request is being made. You can use Wicket's Ajax hooks or jQuery hooks to know when there is an Ajax request.

See https://github.com/reiern70/antilia-bits/tree/master/client-sign-out-parent for an inspiration!

Related