Session timeout message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    Session timeout message

    I'm toying with the idea of displaying a message a few minutes before the user's session is about to expire.

    Every time the user makes a request to the server with their browser the session time is reset.

    The user can be active on the site in multiple tabs in the browser.

    This means that I can't tell if the user's time is about to expire client-side because the user may have made a request to the server in some other tab which would reset the Session timeout time.

    I know this is probably not the best thing to ask but here I go anyway...is there a way to develop a (*wince*) global JavaScript method for all tabs?

    I'm looking into using cookies since they are global...but I'm still curious about global JavaScript methods

    -Frinny
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I’m not aware global objects can access multiple windows/tabs, maybe except the new Storage objects. (and something like Mozilla’s XUL).

    you could try to set a variable so that it contains a timestamp some minutes just before the session gets invalid and make an AJAX call to the server to check the timeout value, whether the session ends in some minutes (display message) or has been extended (set new request timeout).

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      See that's the tricky thing Dorm....
      If I make an Ajax call to the server the Session will be reset.

      That's why I'm thinking cookies are the best way to go for this solution.

      Thanks for the info :)

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        If I make an Ajax call to the server the Session will be reset.
        so you reset the session not by a script, but by request? I thought you could just bypass the reset by calling an appropriate script.

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Session is reset by request :)
          I am not aware of a way to bypass this...at all.
          I don't think it's possible in an ASP.NET web application.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            is that independend of the domain (e.g. www.example.com vs. nosession.examp le.com)?

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              I'm not sure what you're getting at...
              Session dependent on the domain.

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                darn, I was forgetting the SOP.

                sometimes it’s a difference (to the server) if you call http://www.example.com/script1 or http://subdomain.example.com/script2.

                Comment

                • Frinavale
                  Recognized Expert Expert
                  • Oct 2006
                  • 9749

                  #9
                  :) I see what you're getting at now but this is a web application.... any request to it uses the same session. If I requested a different web application under the same domain *I think* it would use a different Session. But I still wouldn't be able to check the session in the first web application....

                  Comment

                  Working...