Search code examples
androidapache-flexmobileflash-builderblackberry-playbook

Flex Mobile remembering user session


I'm creating an app on the Blackberry Playbook that's currently written in Flex using PHP as my backend when querying my SQL Server database.

The first view requires the user to authenticate him/herself with USERID/PASSWORD, and I have a couple stored procedures that just requires the USERID to invoke and return the appropriate data.

What is the "proper" way of retaining the USERID upon switching views after authenticating?

For example, say user "foo" authenticates in my login view, and moves over to the getUserDetails view, which wants to use "foo" as a parameter in a stored procedure that returns a table.

I was thinking of creating a global variable that simply remembers the USERID upon a successful authentication, but feel this isn't the proper way to get around things.

If possible, is there a way to instantiate a user class in PHP in the login view and "remember" that PHP object when transitioning through other views?

Thanks in advance!


Solution

  • What is the "proper" way of retaining the USERID upon switching views after authenticating?

    Proper is open to interpretation. But, you could store such properties in a static class or you could create a singleton class. Both basically boil down to "create a global variable".

    The other alternative is to pass the UserID into every new view component that you create that needs it. This can be tedious; although would be considered proper encapsulation.