1 Reply Latest reply on Aug 27, 2012 1:45 AM by blossoms_bubbles

    Keep User Logged In

    Captain825

      Hi

       

      Using Flash builder 4.6 with a PHP backend.

       

      I am authenticating the user through a username/password login located on State 1, which calls a php script and returns whether or not the user is regsitered.  If so, it grants access to State 2.  My application will have multiple States, all of which I only want the registered user to be able to access.

       

      1. How do I let State 2, or State 3 and so on know that the user is registered and authorized as the user navigates between States without having to have the user login in for each State?

       

      2. Then, once the user logs off or closes the browser, the user would have to re-login.

       

      I know in PHP you can achieve this with $_Sessions but how can I accomplish this in Flex?

       

      Any help would be appreciated.

       

      Thanks

        • 1. Re: Keep User Logged In
          blossoms_bubbles

          You can create a singleton class SessionManager. When the user logs in and you get response from PHP, you set up logged In user in SessionManager. Now whenever the state changes you can check the logged user from this singleton class. When user logs off reset the LoggedUser variable in SessionManager.

           

          What I am telling is just a rough way to implement this you can implement this as per you application needs. Like you can yourself create Singleton class or can use some framework for dependency injection (injection sessionmanager class wherever  needed).

          1 person found this helpful