I have a dynamic web project in Java using Hibernate, servlets and JSP. I want to get the remaining session time for a client so that I can warn them of the upcoming session expiration.
For example, the user would login to the application with one minute of session time. When the remaining session time is ten seconds, I want to warn the user using AJAX and JQuery. How would I do this?
The Session Timeout setting is found on the Global Settings page, in the Security tab. This setting is used to control how long a user session can be inactive in their browser before they are automatically redirected to a pop-up Login window.
Typical session timeouts are 15- to 45-minute durations depending on the sensitivity of the data that may be exposed. As the session timeout is approaching, offer users a warning and give them an opportunity to stay logged in.
The default is 10 minutes. Session. Timeout has no hard-coded limit. Most Web administrators set this property to 8 minutes. It should not be set higher than 20 minutes (except in special cases) because every open session is holding onto memory.
You can make use of HTTPSession.
Make use of current time and apply logic.
Well you cannot actually get session time with an AJAX request as the request it self will also reset the session timeout time. What you can do is get it when you are rendering the page in a js function and start a counter with setTimeout
when and show your message pop when less then 30 seconds left.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With