5 Replies Latest reply on Dec 9, 2008 11:05 AM by ntsiii

    Security Time Out?

    braseth
      I have a Flex 2 application that when first initialized, the user has to log in. How can I enhance that, so after 30 minutes of inactivity, they have to log back in?
        • 1. Re: Security Time Out?
          ozDiGennaro Level 1
          It's not hard at all. Use a timer. The most work will be inserting calls to "restart the timer, because there was activity"

          Below is my functioning code (Flex Builder 3). The restartMyTimer function is designed to accept a function as an argument, and that function is called when the timer times out.
          The overall result for me: change the current state to the base state (""). My function "unviewAll" can be called from many places, so it always stops the timer.

          import flash.utils.Timer;
          import flash.events.TimerEvent
          import flash.display.Sprite;
          // I don't know what the minimum set of "import" is

          private var timer:Timer = new Timer(500, 0); // 500 milliseconds

          ...
          private function restartMyTimer(timeoutFunction:Function):void {
          trace("restartMyTimer");
          timer.stop();
          if (! timer.hasEventListener(TimerEvent.TIMER) ) {
          trace("restartMyTimer add listener");
          timer.addEventListener(TimerEvent.TIMER, timeoutFunction);
          }
          timer.start();
          }\
          ...
          restartMyTimer(unviewAll);
          ...

          private function unviewAll(event:Event):void {
          currentState = "";
          trace("unviewAll" + " " + currentState);
          timer.stop();
          }
          • 2. Re: Security Time Out?
            ntsiii Level 3
            Here is an example. Ancient, you will need to port it to Flex 3, but the theory might help
            http://www.cflex.net/showFileDetails.cfm?ObjectID=309&Object=File&ChannelID=1

            Tracy
            • 3. Re: Security Time Out?
              MBhatt
              Instead of that even you can use FlexSession provided by BalzeDS
              • 4. Security Time Out?
                braseth Level 1
                Is the timer only available in Flex 3 or will I be able to complish this in Flex 2? Going to 3 is not an option.
                • 5. Re: Security Time Out?
                  ntsiii Level 3
                  That example is is Flex 1.5, so yes, you will be able to adapt it for Flex 2. I think it uses setInterval, which will still work but is deprecated.

                  Flex 2 is AS3, so Timer will be available.

                  Tracy