Session Management in Flex – SharedObject
We’re trying to implement a simple Session Management for our end-users to be able to reload the page after signing in to stay signed in.
I did this by utilizing the SharedObject, which can store information on the users computer, regardless if they close the browser or went to a different site.
To create a SharedObject (cannot use the new keyword), and hence is instantiated like so:
private var _so:SharedObject = SharedObject.getLocal("member"); // member here is the name of the cookie stored on the clients computer
To add some parameters to the object stored, you simply:
_so.data.userFirstName = obj.response.firstName; // obj.response.firstname comes from the server after a user signed in
To read from the shared Object located on the users computer:
trace(_so.data.userFirstName) // as you can tell it’s the same way to read, as it is to write.