Nov 18, 2010

Easily write/read Flash Cookies (Local Shared Objects)

On the first frame of the timeline:

local_data = SharedObject.getLocal("user_data");

Writing data
Lets store something in our fresh created Shared Object. Lets say, we want to store the user's name and his age in it. To do so, use this:

local_data.data.user_name = "John Smith";
local_data.data.user_age = 23;
local_data.flush();

Reading data
To retrieve data from a saved Shared Object, just use the following syntax:

stored_user_name = local_data.data.user_name;
stored_user_age = local_data.data.user_age;

SOURCE

No comments: