12 Replies Latest reply on May 6, 2011 6:55 AM by Peter Ondrus

    Display session timeout

    Rémy Mouton Newbie

      Hi @all,


      I need to display the session timeout countdown: Your session will expire in xxx minutes, where xxx goes down every minute and back up to the max when the user does something that resets the countdown.
      Of course regularly refreshing the display should not reset the countdown.


      Thanks in advance for any help!

        • 1. Re: Display session timeout
          Ilya Dyoshin Novice

          you can add the following count down http://www.hashemian.com/tools/javascript-countdown.htm on ajax rendered outputPanel,  the only thing you should check - the target dateTime for the countdown which could be added via some expression. i.e. someTime ( now() would be great )  + session timeout.



          Enytime You made ajax request that would restart the  javascript.


          Pure and simple.



          Kind regards,
          Ilya Dyoshin

          • 2. Re: Display session timeout
            Rémy Mouton Newbie

            Well, thanks, but no, this is not the solution: it counts down by itself instead of asking the server how much time is remaining. So if for some reason the session expires on server side before the counter on browser side has reached 0 (for instance because some javascript operation on browser side, like an alert() dialog, prevents the javascript counter from counting down), the user receives a your session has expired error message that he doesn't understand, and my help desk receives an angry call it says 'session already expired' but displays 'session expires in 10 minutes'!... The counter should display the real value from the server, not a value it has calculated by itself.


            Thanks anyway! Any other solutions?


            Rémy.

            • 3. Re: Display session timeout
              Adrian Mitev Master

              You can't 'ask' the server, because for every request the server will restart the timeout counting.

              • 4. Re: Display session timeout
                Rémy Mouton Newbie

                Yes - I need a way to tell the server that it shouldn't reset the countdown when it answers this special query. It must be some configuration or annotation in Seam...

                • 5. Re: Display session timeout
                  Bernard Labno Master

                  Remy, as Adrian says, every time you ask server, the session gets prolonged.
                  The way this wiki deals with this is having javascript timer that displays countdown, and when it goes down to 0 it shows modal panel with notification about session expiration.
                  There is no possibility to deal with premature session expiration without prolonging it.

                  • 6. Re: Display session timeout
                    Rémy Mouton Newbie

                    OK, thanks. How do I start a RequestForEnhancement?

                    • 7. Re: Display session timeout
                      Thomas Küstermann Newbie

                      How do I start a RequestForEnhancement?


                      Don't even think of it. What do you want to achieve?


                      Christian Bauer posted a nice article on how to handle session timeouts on the client side. You may follow his advice. If you use Richfaces, it is also possible to handle request errors such as session timeouts. Follow up with their reference guide for further information.

                      • 9. Re: Display session timeout
                        Peter Ondrus Newbie

                        Ilya Dyoshin wrote on Mar 15, 2010 15:17:


                        you can add the following count down http://www.hashemian.com/tools/javascript-countdown.htm on ajax rendered outputPanel,  the only thing you should check - the target dateTime for the countdown which could be added via some expression. i.e. someTime ( now() would be great )


                        Enytime You made ajax request that would restart the  javascript.

                        Pure and simple.


                        Kind regards,
                        Ilya Dyoshin


                        Hello, this sounds like a good solution for me. I need to display countdown till the end of an offer. But i do not know how to "add a target time via some expression"
                        Can you help me with this?


                        Thanks.


                        Peter

                        • 10. Re: Display session timeout
                          Tim Evers Master

                          Rémy Mouton wrote on Mar 29, 2010 09:17:


                          OK, got to hell.


                          I assume this is not how you talk to your clients. If you are a professional programmer then you know better then to talk to your peers like this especially when you are asking for FREE support.


                          Now, people are right about the fact that requesting info from the server will automatically refresh your session timeout. This is a fact and there's no good reason to change this. (No your timer is not a good reason).


                          Now, if you took the time to think about your problem you could probably come up with a viable solution that would be accurate enough for 99.99% of a standard user's usage pattern.


                          You are concerned about the javascript countdown being blocked by a poppup/alert and thus no longer being accurate. Fair enough so, what's the logical solution here. On your template page you have a hidden input who's value is a timestamp requested from the server. On the client side on page load you grab the client's timestamp and store it in a javascript variable. Doing a diff on these times gives you the offset between your server time and the client's machine time. You also need to pass in another hidden variable (or hard code it for all anyone cares) the session timeout length.


                          Now assuming you have decent knowledge of javascript and math you could make a countdown that uses the offset and server time stamp, client time and session timeout value to create a countdown that is accurate even if the javascript engine is blocked by an alert for a few mins. (hint, recalculate the timer each time based on server time, client time, offset, and session timeout value)

                          • 11. Re: Display session timeout
                            Rémy Mouton Newbie

                            Please be so kind and tell me how I can stop receiving emails from this forum.


                            At the beginning I was interested a) in solving a certain technical question, b) in adding a feature request. My question a) was answered with what you want is not good and my question b) was answered with we won't let you suggest anything. That's why I aknowledged the encountered openmindedness with the words go to hell. Now, more than one year later, I am not at all interested in an argument about communication forms. So please let me go to hell, by telling me where I can unregister from this forum.

                            • 12. Re: Display session timeout
                              Peter Ondrus Newbie

                              Hi guys,
                              it seems, that both of you have deep knowledge about seam and web development so would you mind to help me, poor beginner, to solve my trivial problem or to pint me to the place where I can find the answer?


                              thanks a lot!


                              Peter