Tuesday, June 3, 2008

cookies in flash

Hi
in this section i like say few tips like how to store cookies with flash...

SharedObject:
This command used to retrieve data from the local system.

SharedObject.getLocal("user_profile");
will get the value from the file called user_profile where each swf will be stored in different location related to the name of the file.

let me specify a example on it

user = SharedObject.getLocal("user_profile");
if (user.data.name == undefined)
{
user.data.name="cookie";
trace("cookie is stored");
}
else
{
trace(user.data.name);
}

let me explain the code above
user = SharedObject.getLocal("user_profile");
this line will read the data from the local system.
if it find any value it will read the value of the variable or it will specify undefined if it is empty.
by checking the value of the variable we can ad the stored cookie value.
The line user.data.name="cookie"; will store the value cookie to the variable user.data.name.

Useful in.
This will be used to store some client detail in to his system like his user name and other detail in his system.
It is also used to find out weather the person has come to our site or not.

No comments: